unlink, “/etc/resolv.conf” and X server

2006年12月11日 20点49分 没有评论

Perl, unlink is used to remove files from directory,syntax “unlink list_of_files”.

/etc/resolv.conf keeps the DNS setting.

Read documents filter out its “#” lines and space lines:
# cat file_name | grep -v # | grep -v ‘^$’

If you have experience in the world of personal computer networking, the term server brings to mind a multiprocessor monster with multiple gigabytes of RAM and disk storage that sits behind glass walls in an air-conditioned machine room and holds all your company’s vital data.

A client is a computer, such as the workstation on your desk, that you use to access and process the information stored on the server.

X-server manages our graphics hardware in a manner similar to how a database server would manage the database, here shared resources is screen, keyboard and mouse.

“This can be a time-consuming and frustrating process.”

Refresh-rate: this is the rate at which the image you see on your screen is redrawn. The refresh rate is expressed in terms of Hertz(HZ). A refresh rate of 60Hz means that an image is redrawn 60 times in one second.

Start the XFree86 X-Server by typing the command:
# X &
# xterm -display localhost:0.0 &

Ctrl+Alt+Backspace send X server a signal that causes it to instantly terminate.
Experiment with this to avoid having to reboot your machine

分类: 科技 标签:

Runt, Serial Port boot defaultly

2006年12月11日 20点34分 没有评论

What is RUNT?
RUNT is Slackware Linux designed to run off of a 128 MB or more USB pen drive. It consists of a boot floppy image and a zip file, similar to zipslack. It is intended to be a fairly complete Linux installation for use as a testing tool capable of booting on any x86 computer with a USB port and a bootable floppy drive. The kernel is slackware’s bare.i kernel. RUNT also contains an initial ramdisk to load usb-storage related modules and it pauses for 5 seconds to allow the drive to initialize. The zip file contains a UMSDOS filesystem designed to be extracted onto a 128 MB pen drive with an msdos filesystem using 2K clusters. (Larger cluster sizes are required for drives larger than 128 MB) The package set is based off of Slackware’s zipslack, but contains other commonly used networking components not available in the zipslack distribution which is limited to 100 MB. RUNT was originally designed for use at North Carolina State University by the ResNet department. ResNet regularly provides support to students in University Housing using their personal computers on the NC State network. RUNT automatically probes for network cards on startup and configures them using DHCP. Although RUNT is intended for use on the NC State network, there is nothing peculiar to our network preventing RUNT from being a useful tool on any network.

What’s required?
A USB 128 MB pen drive with an msdos filesystem using 2K clusters. Larger drives are also acceptable. Most any pen drive will work. Sandisk and Lexar make some of the most popular ones, and they are known to work well. RUNT can also work with any USB storage device such as flash card readers, cameras, watches, etc… Those are the weird ones people have sent in to me. Theoretically RUNT can run off of any FAT drive accessible by the kernel. The bootdisk provided will work with fast USB drives or IDE drives. a USB zip drive takes longer to initialize, and the disk below doesn’t provide adequate time. If you wish to boot RUNT off of SCSI or some other interface, another bootdisk will probably be required. Find or make a Slackware boot disk to meet your needs.
If you can’t boot off of USB, you’ll need a blank floppy.

To boot it you’ll need any x86 based computer cable of USB booting or with a bootable floppy drive and a USB port.

How to install

Unzip the zip file to the FAT partition you intend to run linux off of. If extracing in linux, the drive should be mounted with -t msdos. This doesn’t have to be the only thing on the drive, but make sure the extracted files are in two directory called linux and runtutil in the root of the drive. The process of writing to the USB drive takes a very long time in Windows. You may have better results extracting the file to a hard drive and then copying the linux directory to the USB drive. Also, enabling write-behind caching on the drive may speed it up slightly. This still took me almost an hour though. The fastest way is to just use Linux. It’s done in a few minutes.
In the runtutil directory, run the makeboot.bat(Windows) or makeboot.sh(Linux) script. This will make the ben drive bootable on computers that support it.
If you require a boot floppy, run the mkfloppy.bat(Windows) or mkfloppy.sh(Linux) script.
Restart the computer with the floppy in if necessary and USB drive connected. At the boot prompt just press enter, or provide your own parameters if necessary. If you use a USB floppy drive to boot, you will need to type usbfloppy on the boot prompt. If you are able to boot from USB, you can also type memtest to check the system’s RAM for defects. If you need to select a different keyboard layout, type “usb keymap” at the prompt.
NOTE: Windows NT/2000/XP/2003 is required to perform the operations in makeboot.bat and mkfloppy.sh. If you are using Windows 95/98/Me you should download the boot floppy below and create a floppy using RawWrite for windows. Alternatively you could perform the operation on another computer running Windows NT/2000/XP/2003 or Linux. Booting Knoppix or a similar live distribution will also make this possible.

—From http://runt.mybox.org/

Format the 128 MB USB disk to FAT in Windows OS firstly.
I download runt4.0 zip file, and extract to local harddisk, then copy two folders “Linux” and “runtuti” to formatted USB disk. In fact, the USB capacity is just 108MB, so I had to delete the “man” and “doc” parts in “Linux” directory to ensure copying successfully. In USB “runtui” directory, execute “mkboot.bat” in Windows(I also tested in Linux). Done.

This mini Linux in USB could boot in the machines which has been set related boot order(USB first). It was 2.4.28 with null root password, of course should set password when log in.

Now, I want this Linux to start with Serial port default, which means all its bootable messages and logon informations would be displayed in other machines connected by serial port. As I known, the only one resolution is add supporting console info in lilo or grub, I tried to append “console=ttyS0,9600n8” to “linux.bat” in the USB disk on my Windows environment, it is failed to boot as serial port. Finally, I use this USB boot its mini system, and issue “liloconfig” to view its “lilo.conf” configuration, Yes, I got it(since no lilo.conf file really exists in this slackware like Linux) and created a new “lilo.conf” file by vi.

# Phillip@lilo.conf
boot = /dev/sda
disk = /dev/sda
bios = 0x80
prompt
timeout = 120
change-rules
reset
#vga = normal
image = /boot/vmlinuz
initrd = /boot/initrd.gz
root = /dev/sda1
lable = runt_linux
read-write
append = “console=ttyS0,9600n8”

Save and issue “lilo -C lilo.conf” to make it activated. Is it enough? No, “/etc/inittab” should also be modified, release the “S0” comment and add it to standard console lists:

# These are the standard console login getties in multiuser mode:
s0:2345:respawn:/sbin/agetty -L ttyS0 9600 vt100
c1:1235:respawn:/sbin/agetty 38400 tty1 linux
c2:1235:respawn:/sbin/agetty 38400 tty2 linux
c3:1235:respawn:/sbin/agetty 38400 tty3 linux
c4:1235:respawn:/sbin/agetty 38400 tty4 linux
c5:1235:respawn:/sbin/agetty 38400 tty5 linux
c6:12345:respawn:/sbin/agetty 38400 tty6 linux

# Local serial lines:
# s1:12345:respawn:/sbin/agetty -L ttyS0 9600 vt100
# s2:12345:respawn:/sbin/agetty -L ttyS1 9600 vt100
# Dialup lines:
# d1:12345:respawn:/sbin/agetty -mt60 38400,19200,9600,2400,1200 ttyS0 vt100
# d2:12345:respawn:/sbin/agetty -mt60 38400,19200,9600,2400,1200 ttyS1 vt100

Ok, reboot the mini Linux, when it displays lilo menu, all bootable information was redirected to serial port, I checked the messages in other machined by serial port connection, and log in successfully. Of course, the local also supports login on the screen.

Configure serial port in BIOS is not required, it would also be access by serial port without BIOS rules. I tried to set the serial port in BIOS, Hmm, all the boot messages displayed even contains the basic BIOS checking process.

分类: 科技 标签:

Check User

2006年12月11日 19点58分 没有评论

#! /usr/bin/perl -w
# check users

use User::pwent qw(:FIELDS);
@list = qw(root phillip bruce);
foreach $uu(@list){
print “$uun”;
if(getpwnam $uu) {
print “There’s the $uu.n”;
}
else{
print “No $uu exists.n”;
}
}

分类: 科技 标签:

Perl Net::FTP

2006年12月4日 14点14分 没有评论

Before the wide spread availability of Perl, I would script ftp transfers with .netrc, ksh scripts and other clumsy ways. None of those methods are fun, flexible or easy. On the other hand, Perl’s Net::FTP module is all of that.
With Net::FTP, you have total control. You know when there are errors, timeouts, whatever. It’s not at all difficult: anyone with basic scripting skills can understand and use this.

I’m going to present two programs here. One is very simple; you can probably understand it even if you know no Perl at all. It just logs into my ftp site, gets a listing, and displays it. The other is a fairly complicated program that goes out to a list of hosts and gets files with a date equal to or newer than what you specify. Even with the extra complexity, you should be able to follow it, and perhaps modify it for your own needs.

Here’s the first:
#!/usr/bin/perl
use Net::FTP;
my $host=”192.168.123.68″;
my $directory=”ftptest”;

$ftp=Net::FTP->new($host,Timeout=>240) or $newerr=1;
push @ERRORS, “Can’t ftp to $host: $!n” if $newerr;
myerr() if $newerr;
print “Connectedn”;

$ftp->login(“admin”,”admin”) or $newerr=1;
print “Getting file list”;
push @ERRORS, “Can’t login to $host: $!n” if $newerr;
$ftp->quit if $newerr;
myerr() if $newerr;
print “Logged inn”;

$ftp->cwd($directory) or $newerr=1;
push @ERRORS, “Can’t cd $!n” if $newerr;
myerr() if $newerr;
$ftp->quit if $newerr;

@files=$ftp->dir or $newerr=1;
push @ERRORS, “Can’t get file list $!n” if $newerr;
myerr() if $newerr;
print “Got file listn”;
foreach(@files) {
print “$_n”;
}
$ftp->quit;

sub myerr {
print “Error: n”;
print @ERRORS;
exit 0;
}
Pretty simple, right? Net::FTP makes it all so easy, so let’s do something that would absolutely drive me batty without it.

#!/usr/bin/perl
use Net::FTP;
$date=shift @ARGV;
@months=qw(null Jan Feb Mar Apr My Jun Jul Aug Sep Oct Nov Dec);
@hosts=qw(pcunix.org pcunix.com xyz.com);
@dirs=qw(pub pub pub);
@logins=qw(ftp anonymous fred);
@passwords=qw(tony@ apl@ fxdfed);
$x=0;
foreach(@months) {
$months{$_}=$x++;
}
# we need this hash later
if (not $date) {
$now=time();
$now -= (24 * 3600 );
# yesterday
($nowsec,$nowmin,$nowhr,$nowday,$nowmon,$nowyr,$nowdow,$nowdoy,$nowdst)=localtime($now);
$nowyr+=1900;$nowmon++;
$date=sprintf(“%.2d/%.2d/%.4d”,$nowmon,$nowday,$nowyr);
print “Using $daten”;
}
$now=time();
($nowsec,$nowmin,$nowhr,$nowday,$nowmon,$nowyr,$nowdow,$nowdoy,$nowdst)=localtime($now);
$nowyr+=1900;

# need $nowyr later
($month,$day,$year)=split ///,$date;
#
# broken next century – blame me then
#
$year+=2000 if $year < 100; $x=0; foreach (@hosts) { $newerr=0; $ftp=Net::FTP->new($_,Timeout=>240) or $newerr=1;
push @ERRORS, “Can’t ftp to $_: $!n” if $newerr;
next if $newerr;
print “Connected $_n”;

$ftp->login($logins[$x],$passwords[$x]) or $newerr=1;
push @ERRORS, “Can’t login to $_: $!n” if $newerr;
$ftp->quit if $newerr;
next if $newerr;
print “Logged in $_n”;

$ftp->cwd($dirs[$x]) or $newerr=1;
push @ERRORS, “Can’t cd $dirs[$x] on $_ $!n” if $newerr;
$ftp->quit if $newerr;
next if $newerr;
print “Getting file list $_n”;

@files=$ftp->dir or $newerr=1;
push @ERRORS, “Can’t get file list on $_ $!n” if $newerr;
$ftp->quit if $newerr;
next if $newerr;
print “Got list $_n”;
print “Looking for $date $timen”;

foreach(@files) {
$_=substr($_,41);
s/ */ /g;
s/^ *//g;
chomp;
@stuff=split / /;
# if it’s today, the year slot will have time instead
# so make it this year
$stuff[2]=$nowyr if /:/;
$ftp->quit if ($stuff[2] < $year); next if ($stuff[2] < $year); $ftp->quit if ($months{$stuff[0]} < $month and $stuff[2] == $year); next if ($months{$stuff[0]} < $month and $stuff[2] == $year); $ftp->quit if ($stuff[0] < $day and $stuff[2] == $year and $months{$stuff[0]} == $month); next if ($stuff[1] < $day and $stuff[2] == $year and $months{$stuff[0]} == $month); print "Getting $_n"; $ftp->get($stuff[3],$stuff[3]) or $newerr=1;
push @ERRORS, “Couldn’t get $stuff[3] $!n” if $newerr;
}
$ftp->quit;
}
print @ERRORS;
exit 0;

分类: 科技 标签:

Save private “LAT”

2006年12月3日 12点27分 没有评论

Mount my harddisk to new machines, XP down, but CentOS/LAT would still startup. I want to play 3C with my fellows, and it’s two slowly in Linux cedege, I had to install a new XP without losing my private “LAT”. Grub manages the boot of harddisk, when choose boot from XP, blue screen happenes. The XP must be re-installed. Finally, I resolve this trouble by the following steps.

Add another new IDE harddisk , set it as “Master” and the old one as “Slave” , then boot from CD-ROM(XP CD inside) to install XP in master harddisk. Install a fresh mini CentOS on master, it will also use grub. Modify this mini CentOS’s grub.conf(Refer the former /boot/grub/grub.conf), and the “CentOS/LAT” entry. Yes, the private “LAT” was saved.

分类: 科技 标签:

Patch apply

2006年12月3日 12点17分 没有评论

# $errnum = system(“$config{‘update_system_cmd’} $install_file doit_in_foreground >/dev/null 2>&1”);
#`echo Start install parameters – update.cgi – force install:$force_install >> /tmp/gui.dbg`;

my $TMP_LOG = “/tmp/tmp_install_patch.log”;
`echo “” > $TMP_LOG`;
my $cmd_out = system(“$config{‘update_system_cmd’} $install_file $force_install install 1>/dev/null 2>$TMP_LOG &”);
print qq(
);
print qq(

);

my $ps = 0;
my $pat = “Patching the system OS software under maintenance mode!”;
my $line_num = 1;
my $lines;
while(!$ps){
`ps -aef | grep SYS_InstallStartOSInstall | grep -v grep`;
$ps = $?;
my @var = `sed -n ‘$line_num,$p’ $TMP_LOG | grep -v DBG | sed s/^[][]*/”

“/`;
foreach $vv(@var){
if($vv=~m/$pat/){
print qq(

);;
$pat_line = `cat -n $TMP_LOG | wc -l`;
$line_num = $pat_line + 1;
}
elsif(defined $pat_line){
if(not $vv=~m/^&/ and not $vv=~m/error/ and not $vv=~m/arning/){
print qq(

);
$lines = `cat -n $TMP_LOG | wc -l`;
$line_num = $lines + 1;
}
}
else{
$lines = `cat -n $TMP_LOG | wc -l`;
$line_num = $lines + 1;
}
}
sleep 0.1;
}

print qq(

Patch Apply

$vv
$vv

);
`cat $TMP_LOG >> $INSTALL_LOG`;
my $sta = grep /Succeed/, $TMP_LOG;
button_table_start();

if(!$sta){
# print “sta=$stan”;
print “Patch install successfully, please reboot your systemn”;
print qq(


n);
print qq(

);
write_action_button(“reboot”,$software_26,”javascript:document.rebootForm.submit()”);
print qq(
);
exit 0;
}
else{
print “Install failedn”;
write_action_button(“back”,”<< $software_10","index.cgi"); print "sta=$stan"; exit 0; } button_table_end(); `rm -rf $TMP_LOG`;

分类: 科技 标签:

ftp share_info, share_modify

2006年12月3日 12点01分 没有评论

sub share_info($$)
{
my $invocant = shift;
my $share = shift;
unless( defined $share) {
ftp_error->set_error( $ftp_error::error_parameter );
return undef;
}
my $cfg = Config::IniFiles->new();
unless( $cfg) {
ftp_error->set_error( $ftp_error::error_file_IO);
return undef;
}
$cfg->SetFileName($file_share_config);
$cfg->ReadConfig();
return $error_share_not_exist unless( $cfg->SectionExists($share));
my $pathname = $cfg->val( $share, $tag_pathname);
my $guest = $cfg->val( $share, $tag_guest);
my $readonly = $cfg->val( $share, $tag_readonly);
my $hide = $cfg->val( $share, $tag_hide);
return ($share, $pathname, $guest, $readonly, $hide);
}
…..
sub share_modify($$$$$$)
{
my $invocant = shift;
my( $share, $pathname, $guest, $readonly, $hide) = @_;
unless( defined $share && defined $pathname
&& defined $guest && defined $readonly && defined $hide) {
ftp_error->set_error( $ftp_error::error_parameter );
return undef;
}
……

分类: 科技 标签:

Program: fix two P1 bugs

2006年12月3日 11点48分 没有评论

In the last two weeks, I fixed two P1 bugs. One is saving setting when update ftp share, the other is displaying patch install process. Almostly all my energy were put into programming. It’s so long that I did not touch program since 2002 writing ASP in Wuhan. I read many Perl manuals to learn the perl syntax and try to apply it in a short time, though in fact, these two fixing took me nearly two weeks. It was low working-rate. I’m still pleased with my working, a famous German writer said “It maybe not the best, but is good as being finished.”

I learn more from two cases not only Perl experience, but also, the most important thing, I am really programmer. The programing seems to be annoyed and charming job, some lines of code could work as what you want. Still do I have litter difficult in improve the rate, and I believe I could be more familar with more practises.

More patience, will get more. Read the whole program first, do more thinking, then start modify. Bruce said, the preparing work is the key during fixing problems. Sometimes, perhaps I’m too anxious to have enough preparing thinking, it wasted my external spirit to try and try. It’s not benifit for me. I’ll pay more attention on the ready process.

nscd and RAID6 will be the next points researched.

I’ve been in Plasmon for four months. Before Dec,25th, we will fly to Sanya for our holiday, and I brought a DV last week. In the December of last year, I did not go to Hainan even emergency AF2 issue happened in Hainan.

分类: 科技 标签:

Week summary

2006年11月19日 21点26分 没有评论

Spin out/in SATA module from kernel when physically remove the drivers, especial Hot-Swap case. I did a whole testing on SNAZ-S4-400 platform(RAID0, 1,5), plug the disk out when there’s (or not) I/O, when the “miss” hard disk inserted back, the RAID were all recoveried. Bruce said, Irish had produced many disk failure issues when hotswap. I would follow up this testing and plan to use larger I/O pression.

“smbpasswd” add user to LDAP
1.In the “/etc/samba/smb.conf”, modify the second line as the following:
Passdb backend=ldapsam: ldap://192.168.123.33:389
This means the new users will be added here.
2.In localhost, # adduser phillip
# smbpasswd -a phillip
3. Then issue “ldapsearch -x”, the new user “phillip” is in the returned entries.

IE 7.0 running as IE6.0:
Microsoft supplied UASU tool for opening an IE7.0 instruce that emluates IE6 by sending the IE6 use agent string. I downloaded UASU.msc and installed, it works well on IE7.0 platform.

Perl, for about two months, I restarted to learn it now, and I must pay more attention on enhancing my program ability, such as read, write and debug. Bruce gave me a good advice, learn this program when using it, read the manul when needed. I think it is right and will be on this learning road. My schedule is spending one week, to master this program as almost our general programs are all written in Perl.

Before do anything, think about it careful, try to make it more clearly. Then, just do it.

分类: 科技 标签:

RAID commands

2006年11月13日 21点07分 没有评论

Check the RAID setting by running the following command:
# cat /proc/mdstat
Personalites: [md5]
md0: active raid5 sdd1[2] sde1[3] sdc1[1] sdb1[0]
75469842 blocks level 5, 128k chunk, algorithm[3/3] [UUU]
Here, the first “3” in “[3/3]” indicates the how many devices in the array; the second “3” means active device numbers. If one device in array has been destoried, the second number would decrease “1”, for example, one disk failed, the second number is “2” as the result of “3-1”.
“UUU” marks the currently using device status. Assume /dev/sdb1 failed, it should be [_UU], at this point, the array runs in degrade mode without redundant.
“sdd1[2]”, assume “n” is the number of devices in array: if the number in “[]” is less than “n”, it means the device is active,else if the device is for backup. When one device down, the coresponding “[]” will be marked as “[F]”.

Mark the /dev/sdb1 as failed:
# mdadm /dev/md0 -f /dev/sdb1
Note, in this case, “/dev/sdb1” was component of “/dev/md0”.

Remove failed device:
# mdadm /dev/md0 -r /dev/sdb1

Add device to array:
# mdadm /dev/md0 -a /dev/sdb1

Start all arrays in “mdadm.conf”
# mdadm -As

Start idenfied array:
# mdadm -As /dev/md0

Stop array:
# mdadm -S /dev/md0

List detail information:
# mdadm -D /dev/md0

分类: 科技 标签: