Friday, August 31, 2012

How to change the mac adress in Fedora


1.[root@localhost ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:23:8B:6A:7E:9E
inet addr:10.1.128.244 Bcast:10.1.255.255 Mask:255.255.0.0
inet6 addr: fe80::218:8bff:fedb:7e9e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:79086 errors:0 dropped:0 overruns:0 frame:0
TX packets:40319 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:72461556 (69.1 MiB) TX bytes:5245562 (5.0 MiB)
Interrupt:17


Here, eth0 is the ethernet interface of your system. The mac address is put in red.

2. Change your mac address using the following syntax

ifconfig eth0 hw ether 00:18:8B:CA:7E:90

The new value (in green) must be hexadecimal

3. if you have a dhcp server that distributes the adresses automatically, then request a new adress for your eth0 interface

[root@localhost ~]# dhclient eth0

5. Now, your interface is up and have a new mac and IP addresses. This feature may be useful if the network administrator ban you according to the mac adress, for example .........

 

With Thanks & Regards,

Rajesh S

 

Device eth0 does not seem to be present, delaying initialization

# service network restart
Bringing up interface eth0:  Device eth0 does not seem to be present, delaying initialization.
[FAILED]

I Checked the message buffer of the kernel, it prompted eth0 had been renamed to eth3, and eth1 to eth2.
# dmesg|grep eth
… …
[    4.494092] udev[396]: renamed network interface eth1 to eth2
[    4.549086] udev[396]: renamed network interface eth0 to eth3

So I created the configuration files for eth2 and eth3.
# cd /etc/sysconfig/network-scripts
# mv ifcfg-eth1 ifcfg-eth2
# mv ifcfg-eth0 ifcfg-eth3

Modify the DEVICE to eth2 and eth3 in ifcfg-eth2 and ifcfg-eth3 files respectively using vi editor.

Restart the network servcie, it reminded me they used different MAC address.
# service network restart
Bringing up interface eth3:  Device eth3 has different MAC address than expected, ignoring.
[FAILED]

Get their MAC addresses, and append them to ifcfg-eth2 and ifcfg-eth3 files.
# cat /sys/class/net/eth2/address >> ifcfg-eth2
# cat /sys/class/net/eth3/address >> ifcfg-eth3

Use vi editor to change the MAC addresses to the appended.

Restart the network service again, they worked.

 

 

With Thanks & Regards,

Rajesh S

 

Tuesday, August 28, 2012

How to make USB as bootable disk

 

Open diskpart.exe

And execute the following cmds

·         list disk

·         select disk # (#--> 1 or which disk u want to format : ex select disk 1)

·         clean

·         create partition primary

 

 

With Thanks & Regards,

Rajesh S

 

Friday, August 3, 2012

Launch any file path from web page

Launch any file path from web page

 

<html>

<head>

<base href="file://">

<script>

function DoIt() {

  alert(document.getElementById("cmdToRun").value);

  document.location=document.getElementById("cmdToRun").value;

}

</script>

</head>

<body>

<select id="cmdToRun">

<option value="/usr/sbin/netstat">Launch /usr/bin/netstat</option>

<option value="/etc/passwd">Launch /etc/passwd</option>

<option value="/Applications/Utilities/Bluetooth File Exchange.app">

Launch Bluetooth File Exchange.app</option>

</select>

<br />

<input type=button value="Launch" onclick="DoIt()">

<br />

</body>

</html>

 

Monday, July 23, 2012

C Program To Download File From Http Server

#include <stdio.h>

#include <sys/socket.h>

#include <arpa/inet.h>

#include <stdlib.h>

#include <netdb.h>

#include <string.h>

int create_tcp_socket();

char *get_ip(char *host);

char *build_get_query(char *host, char *page);

void usage();

 

#define HOST "coding.debuntu.org"

#define PAGE "/"

#define PORT 80

#define USERAGENT "HTMLGET 1.0"

 

int main(int argc, char **argv)

{

  struct sockaddr_in *remote;

  int sock;

  int tmpres;

  char *ip;

  char *get;

  char buf[BUFSIZ+1];

  char *host;

  char *page;

 

  if(argc == 1){

    usage();

    exit(2);

  } 

  host = argv[1];

  if(argc > 2){

    page = argv[2];

  }else{

    page = PAGE;

  }

  sock = create_tcp_socket();

  ip = get_ip(host);

  fprintf(stderr, "IP is %s\n", ip);

  remote = (struct sockaddr_in *)malloc(sizeof(struct sockaddr_in *));

  remote->sin_family = AF_INET;

  tmpres = inet_pton(AF_INET, ip, (void *)(&(remote->sin_addr.s_addr)));

  if( tmpres < 0) 

  {

    perror("Can't set remote->sin_addr.s_addr");

    exit(1);

  }else if(tmpres == 0)

  {

    fprintf(stderr, "%s is not a valid IP address\n", ip);

    exit(1);

  }

  remote->sin_port = htons(PORT);

 

  if(connect(sock, (struct sockaddr *)remote, sizeof(struct sockaddr)) < 0){

    perror("Could not connect");

    exit(1);

  }

  get = build_get_query(host, page);

  fprintf(stderr, "Query is:\n<<START>>\n%s<<END>>\n", get);

 

  //Send the query to the server

  int sent = 0;

  while(sent < strlen(get))

  {

    tmpres = send(sock, get+sent, strlen(get)-sent, 0);

    if(tmpres == -1){

      perror("Can't send query");

      exit(1);

    }

    sent += tmpres;

  }

  //now it is time to receive the page

  memset(buf, 0, sizeof(buf));

  int htmlstart = 0;

  char * htmlcontent = NULL;

  while((tmpres = recv(sock, buf, BUFSIZ, 0)) > 0){

    if(htmlstart == 0)

    {

      /* Under certain conditions this will not work.

      * If the \r\n\r\n part is splitted into two messages

      * it will fail to detect the beginning of HTML content

      */

      htmlcontent = strstr(buf, "\r\n\r\n");

      if(htmlcontent != NULL){

        htmlstart = 1;

        htmlcontent += 4;

      }

    }else{

      htmlcontent = buf;

    }

    if(htmlstart){

      fprintf(stdout, "%s", htmlcontent);

    }

    memset(buf, 0X0, tmpres);

  }

  if(tmpres < 0)

  {

    perror("Error receiving data");

  }

  free(get);

  free(remote);

  free(ip);

  close(sock);

  return 0;

}

 

void usage()

{

  fprintf(stderr, "USAGE: htmlget host [page]\n\

\thost: the website hostname. ex: coding.debuntu.org\n\

\tpage: the page to retrieve. ex: index.html, default: /\n");

}

 

 

int create_tcp_socket()

{

  int sock;

  if((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0){

    perror("Can't create TCP socket");

    exit(1);

  }

  return sock;

}

 

 

char *get_ip(char *host)

{

  struct hostent *hent;

  int iplen = 15; //XXX.XXX.XXX.XXX

  char *ip = (char *)malloc(iplen+1);

  memset(ip, 0, iplen+1);

  if((hent = gethostbyname(host)) == NULL)

  {

    herror("Can't get IP");

    exit(1);

  }

  if(inet_ntop(AF_INET, (void *)hent->h_addr_list[0], ip, iplen) == NULL)

  {

    perror("Can't resolve host");

    exit(1);

  }

  return ip;

}

 

char *build_get_query(char *host, char *page)

{

  char *query;

  char *getpage = page;

  char *tpl = "GET /%s HTTP/1.0\r\nHost: %s\r\nUser-Agent: %s\r\n\r\n";

  if(getpage[0] == '/'){

    getpage = getpage + 1;

    fprintf(stderr,"Removing leading \"/\", converting %s to %s\n", page, getpage);

  }

  // -5 is to consider the %s %s %s in tpl and the ending \0

  query = (char *)malloc(strlen(host)+strlen(getpage)+strlen(USERAGENT)+strlen(tpl)-5);

  sprintf(query, tpl, getpage, host, USERAGENT);

  return query;

}

 

Tuesday, June 12, 2012

Error: RPC MTAB does not exist.

Error: RPC MTAB does not exist.

# service nfs start
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]
Starting RPC idmapd: Error: RPC MTAB does not exist.

 

or



# service rpcidmapd start

Starting RPC idmapd: Error: RPC MTAB does not exist.

 


solution:

--------

1)  mount -t nfsd nfsd /proc/fs/nfsd

 

2) mount -t rpc_pipefs sunrpc /var/lib/nfs/rpc_pipefs/

 

3) reload the nfs 

4) reload the rpcidmapd

 

Monday, May 14, 2012

Java scipt delay & automatic redirection code

<html>

<head>

<script type="text/javascript">

<!--

function delayer(){

    window.location = "../javascriptredirect.php"

}

//-->

</script>

</head>

<body onLoad="setTimeout('delayer()', 10)">

<h2>Prepare to be redirected!</h2>

<p>This page is a time delay redirect, please update your bookmarks to our new

location!</p>

 

</body>

</html>

Handling the ESC key in java script

<html>  

<head>  

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  

<title>JSP Page</title>  

<script type="text/javascript">  

function identifyEscKeyPressedEvent(keyEvent)  

{                 

var pressedKeyValue = keyEvent.keyCode;  

if(pressedKeyValue == 27)  

{  

alert("Esc Key is pressed");  

}  

else  

{  

alert("You have other Key is pressed");  

}  

}  

</script>  

</head>  

<body>          

<input type="text" name="testName"   onkeypress="return identifyEscKeyPressedEvent(event);"/>  

</body>  

</html>  

Monday, April 30, 2012

How to Copy (Backup) a MySQL Database

How to Copy (Backup) a MySQL Database

MySQL databases are tricky files to copy - you must be careful with them. However once you understand the issues and have procedures in place you shouldn't experience any problems. MySQL is actually designed to make backing up a smooth and reliable process.

Simple Copy

The easiest method is to simply copy the binary database files. However this may create problems and is not the recommended copying method. For example, the different ways of handling case-sensitivity between Unix and Windows means that a database copied from one system to the other may become corrupt.

Using the mysqldump Command

The mysqldump command creates a text version of the database. Specifically, it creates a list of SQL statements which can be used to restore/recreate the original database.

The syntax is:

$ mysqldump -u [uname] -p[pass] [dbname] > [backupfile.sql]

[uname]

Your database username

[pass]

The password for your database

[dbname]

The name of your database

[backupfile.sql]

The filename for your database backup

You can dump a table, a database, or all databases.

To dump all MySQL databases on the system, use the --all-databases shortcut:

$ mysqldump -u root -p --all-databases > [backupfile.sql]

Restoring a MySQL Database

Use this method to rebuild a database from scratch:

$ mysql -u [username] -p [password] [database_to_restore] < [backupfile]

Use this method to import into an existing database (i.e. to restore a database that already exists):

$ mysqlimport [options] database textfile1

To restore your previously created custback.sql dump back to your 'Customers' MySQL database, you'd use:

$ mysqlimport -u sadmin -p pass21 Customers custback.sql

 

Tuesday, April 24, 2012

Crack website

http://cracksapps.blogspot.in/2012/04/easy-button-and-menu-maker-serial-key.html