Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/perl
- #Simple script to change the hostname with PcLinuxOs.
- #Of course you must be logged as root.
- #ATTENTION: this program is free software, so it came with _ABSOLUTE_
- #NO WARRANTY! I'm not responsable if this software erase your hard disk,
- #empty your bank account, stole your car, destroy your furnitures, set
- #your house in fire, seduces your wife and kill your dog.
- print "To change the hostname you must be logged as root.\n";
- RESTART: #Here is the Label to restart the selection of hostname if user use spaces...
- print "Choose your hostname:
- (You can't choose name with spaces)\n";
- $hostname=<STDIN>;
- chomp($hostname);
- $hostname =~ s/^\s+//; #Remove all spaces before the hostname
- if($hostname =~ s/\s//g) #Check for some spaces in the hostname
- {
- print "I told you that you can't choose name with spaces!\n";
- goto RESTART; #Yes, I know I shouldn't use goto...
- }
- else
- {
- print "You chose $hostname\n";
- }
- $file1="/etc/sysconfig/network";
- open(FILE1,">$file1") or die "Error! Can't open the file:\n$file1\n";
- print FILE1 "HOSTNAME=$hostname
- NETWORKING=yes
- CRDA_DOMAIN=US";
- close(FILE1);
- $file2="/etc/hosts";
- open(FILE2,">$file2") or die "Error! Can't open the file:\n$file2\n";
- print FILE2 "# generated by drakconnect
- 127.0.0.1 $hostname localhost.localdomain localhost";
- close(FILE2);
- print "Your hostname will be changed at the next reboot.
- Now you can continue to watch Porn or do whatever you want!\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement