存档

2006年12月 的存档

Install Novell eDirectory Service in Linux

2006年12月11日 没有评论

Novell Directory Services (NDS) debuted in 1994, and was derived from the Xerox X.500 database scheme. Although NDS was, and still is, primarily, the facility that allowed you to create users and groups on the Netware network. Novell eDirectory has the ability to exist on many platforms, other than Netware, including Windows NT/2000, Linux and Solaris.

gettext must be installed. gettext is, according to its website, “a set of tools that provides a framework to help other GNU packages produce multi-lingual messages”.

1. Pre-Install
Before beginning the installation, you will need to check certain parameters in your Linux server/workstation :
Enable Multicasting. You will need to check your routing table for an existing specific multicasting entry. Login as root and execute the following command,

#/bin/netstat -rn

Existing routes will be printed to screen. Look for the following entry

224.0.0.00.0.0.0

If you do not see this, then you will need to add the necessary entry. Again, as root user, execute the following command, (this assumes that you have just one network card and it is recognized by your system as eth0.

#route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0

If you have more than one eDirectory server on the same network. You will need to use NTP to synchronize the time on your systems. You probably should have an NTP server configured on your network, if your company is fairly large. I have encountered problems starting my eDirectory server if the NTP connection is lost or unavailable. An indication that this may be the problem is when the NDS daemon fails to start at boot time.

2. Install nds8.8
Register novell user and download nds8.8 iso for Linux.
[root@localhost /]# mount -o loop edir_88_linux.iso /mnt
[root@localhost /]# cd /mnt/setup
[root@localhost setup]# ./nds-install
%%% Welcome to the installation of Novell eDirectory.
%%% The Novell eDirectory 8.8 for Linux End User License Agreement will now be displayed.
%%% Please read the agreement carefully before accepting the terms.
%%% Press ENTER to continue.

Novell(r) eDirectory(r) 8.8
Novell Software License Agreement
PLEASE READ THIS AGREEMENT CAREFULLY, BY INSTALLING OR OTHERWISE USING THE SOFTWARE, YOU AGREE TO THE TERMS OF THIS AGREEMENT. IF YOU DO NOT AGREE WITH THESE TERMS, DO NOT DOWNLOAD, INSTALL OR USE THE SOFTWARE. THE SOFTWARE MAY NOT BE SOLD, TRANSFERRED, OR FURTHER DISTRIBUTED EXCEPT AS AUTHORIZED BY Novell.
This Novell Software License Agreement (“Agreement”) is a legal agreement between You (an entity or a person) and Novell, Inc. (“Novell”). The software product identified in the title of this Agreement, media (if any) and accompanying documentation (collectively the “Software”) is protected by the copyright laws and treaties of the United States (“U.S.”) and other countries and is subject to the terms of this Agreement. If You do not agree with the terms of this Agreement, do not download, install or otherwise use the Software and, if applicable, return the entire unused package to the reseller with Your receipt for a refund. The Software is licensed to You, not sold.
The Software may include or be bundled with other software programs licensed under different terms and/or licensed by a licensor other than Novell. Use of any software programs accompanied by a separate license agreement is governed by that separate license agreement. Any third party software that may be provided wit

%%% Do you accept the terms of Novell eDirectory 8.8 license agreement ‘[y/n/q] ? y

%%% List of Novell eDirectory 8.8 components available to install

%%% 1 Novell eDirectory Server
%%% 2 Novell eDirectory Administration Utilities

%%% Select the components you wish to install [?, q] : 1,2

%%% Installing NICI-2.7.0…

%%% Adding packages…

%%% Installing novell-NDSmasv… done
%%% Installing novell-NDSbase… done
%%% Installing novell-NLDAPsdk… done
%%% Installing novell-NLDAPbase… done
%%% Installing novell-NDScommon… done
%%% Installing novell-pkiserver… done
%%% Installing novell-npkiapi… done
%%% Installing novell-npkit… done
%%% Installing novell-NOVLsas… done
%%% Installing novell-ntls… done
%%% Installing novell-ncpenc… done
%%% Installing novell-NDSserv… done
%%% Installing novell-NDSrepair… done
%%% Installing novell-NOVLstlog… done
%%% Installing novell-NOVLsubag… done
%%% Installing novell-nmas… done
%%% Installing novell-NOVLxis… done
%%% Installing novell-NOVLlmgnt… done
%%% Installing novell-NOVLembox… done
%%% Installing novell-NOVLsnmp… done
%%% Installing novell-NDSimon… done
%%% Installing novell-NOVLice… done

%%% Use “ndsconfig” or “ndsmanage” to configure Novell eDirectory Server.

%%% To use eMBox you need JRE version 1.4 or above. If your default version doesn’t work then update the PATH variable as follows to use jre version 1.4
PATH=$PATH:/opt/novell/eDirectory/lib/nds-modules/embox/jre/bin

%%% WARNING: The user should install openslp or NDSslp(version-8.8) package for using SLP services.

%%% Please update the following environment variables and export them or run /opt/novell/eDirectory/bin/ndspath to set the environment for Novell eDirectory 8.8
PATH=/opt/novell/eDirectory/bin:/opt/novell/eDirectory/sbin:$PATH
LD_LIBRARY_PATH=/opt/novell/eDirectory/lib:/opt/novell/eDirectory/lib/nds-modules:/opt/novell/lib:$LD_LIBRARY_PATH
MANPATH=/opt/novell/man:/opt/novell/eDirectory/man:$MANPATH

%%% Please go through /c/setup/../readme.txt carefully before using the product.
%%% Novell eDirectory Server packages successfully installed.

%%% Novell eDirectory Administration Utilities packages successfully installed.

Then vi /root/.bash_profile, and the following items and log again.

export SHLIB_PATH=/opt/novell/eDirectory/lib:/opt/novell/eDirectory/lib/nds-modules:/opt/novell/lib:$SHLIB_PATH
export PATH=/opt/novell/eDirectory/bin:/opt/novell/eDirectory/sbin:$PATH
export MANPATH=/opt/novell/man:/opt/novell/eDirectory/man:$MANPATH
export TEXTDOMAINDIR=/opt/novell/eDirectory/share/locale:$TEXTDOMAINDIR

2. Install ConsoleOne 1.3.6f
Download ConsoleOne 1.3.6f tarball from novell site, then compress to “Linux” directory.
[root@localhost root]# tar zxvf c1_136f-linux.tar.gz
[root@localhost root]# cd Linux
[root@localhost Linux]# ./c1-install
Welcome to the installation of ConsoleOne 1.3.6f

The following is a list of languages that are available to install.
1 English
2 Chinese
3 Chinese Traditional
4 French
5 German
6 Italian
7 Japanese
8 Portuguese
9 Russian
10 Spanish
11 All
Select the languages you wish to install [?,q]: 1

The following are all the available snapins you can choose to install
0 NONE
1 ICE Snapin
2 Index Manager Snapin
3 LDAP Snapin
4 SLP Snapin
5 WAN Manager Snapin
6 PKI Snapin
7 Filtered Replica Snapin
8 All
Select the snapin(s) you wish to install [?,q]: 8

———————————————-
Linux Kernel Version installed in this system:
2.4.21-32.EL
———————————————-

Do you wish to install Java Runtime Environment [y,n,q] ? y

%% A later version of NICI (2.7.0) is already present on this system.
%% The version of NICI available with this distribution (2.6.4) was not installed.
%% Adding package NOVLc1Linuxjre …
Preparing… ########################################### [100%]
1:NOVLc1Linuxjre ########################################### [100%]
%% Adding package NDSslp …
Preparing… ########################################### [100%]
1:NDSslp ########################################### [100%]
%% Adding package NDSbase …
Preparing… ########################################### [100%]
1:NDSbase ########################################### [100%]
%% Adding package NDScommon …
Preparing… ########################################### [100%]
1:NDScommon ########################################### [100%]
%% Adding package NLDAPsdk …
Preparing… ########################################### [100%]
1:NLDAPsdk ########################################### [100%]
%% Adding package NLDAPbase …
Preparing… ########################################### [100%]
1:NLDAPbase ########################################### [100%]
%% Adding package NOVLxis …
Preparing… ########################################### [100%]
1:NOVLxis ########################################### [100%]
%% Adding package NOVLlmgnt …
Preparing… ########################################### [100%]
1:NOVLlmgnt ########################################### [100%]
%% Adding package NOVLice …
Preparing… ########################################### [100%]
1:NOVLice ########################################### [100%]
%% Adding package NOVLsas …
Preparing… ########################################### [100%]
1:NOVLsas ########################################### [100%]
%% Adding package NOVLpkia …
Preparing… ########################################### [100%]
1:NOVLpkia ########################################### [100%]
%% Adding package NOVLpkis …
Preparing… ########################################### [100%]
1:NOVLpkis ########################################### [100%]
%% Adding package NOVLc1 …
Preparing… ########################################### [100%]
1:NOVLc1 ########################################### [100%]
%% Adding package NDSsice …
Preparing… ########################################### [100%]
1:NDSsice ########################################### [100%]
%% Adding package NDSsimgr …
Preparing… ########################################### [100%]
1:NDSsimgr ########################################### [100%]
%% Adding package NDSsldap …
Preparing… ########################################### [100%]
1:NDSsldap ########################################### [100%]
%% Adding package NDSsslp …
Preparing… ########################################### [100%]
1:NDSsslp ########################################### [100%]
%% Adding package NDSswan …
Preparing… ########################################### [100%]
1:NDSswan ########################################### [100%]
%% Adding package NDSspki …
Preparing… ########################################### [100%]
1:NDSspki ########################################### [100%]
%% Adding package NDSsfrep …
Preparing… ########################################### [100%]
1:NDSsfrep ########################################### [100%]
%% Java Runtime Environment Successfully Installed.
%% ConsoleOne Successfully Installed.
%% Execute /usr/ConsoleOne/bin/ConsoleOne to run ConsoleOne
%% Snapins Successfully Installed.
NDSslp-8.7.3-13
Starting NDS SLP services…
Done

4. Set up the tree
[root@localhost root]# ndsconfig new -t Plasmon -n o=Plasmon -a cn=PlasmonAdmin.o=Plasmon
Enter the password for cn=PlasmonAdmin.o=Plasmon:
Re-enter the password for cn=PlasmonAdmin.o=Plasmon:
Please enter the absolute path for the instance [ /var/opt/novell/eDirectory ]:
Please enter absolute path of the database directory [ /var/opt/novell/eDirectory/data/dib ]:
Configuring the NDAP interfaces… Done
Configuring the LDAP interfaces… Done
Configuring the HTTP interfaces… Done
Starting the service ‘ndsd’… Done.
Configuring Novell eDirectory server with following parameters
Admin name = cn=PlasmonAdmin.o=Plasmon
Tree name = Plasmon
Server Context = o=Plasmon
DIB location = /var/opt/novell/eDirectory/data/dib
Searching for Duplicate Tree Name in the network. Please wait…
Basic configuration is successful. Proceeding with additional configuration…
Extending schema… Done
For more details view schema extension logfile: /var/opt/novell/eDirectory/log/schema.log
Configuring HTTP service… Done
Configuring LDAP service… Done
Configuring SNMP service… Done
Configuring SAS service… Done
Associating certificate with the NCP server object… Done
Configuring NMAS service… Done
Configuring SecretStore… Done
Configuring LDAP Server with default SSL CertificateDNS certificate… Done
The instance at /etc/opt/novell/eDirectory/conf/nds.conf is successfully configured.

Check the service stauts:
[root@localhost root]# ndsstat
[1] Instance at /etc/opt/novell/eDirectory/conf/nds.conf: localhost.o=Plasmon.PLASMON
Tree Name: PLASMON
Server Name: .CN=localhost.O=Plasmon.T=PLASMON.
Binary Version: 20112.91
Root Most Entry Depth: 0
Product Version: eDirectory for Linux v8.8 [DS]
5. Setting Up hosts.nds
If you are installing eDirectory on a pristine Red Hat system, you may have default firewall rules that block the Service Location Protocol (SLP). SLP functions like the “Network Neighbourhood” of Microsoft Windows, in that it broadcasts available services on the network, and enable applications like ConsoleOne to “know” what services are available. If SLP is blocked, you will not be able to “browse” for the eDirectory server.

In any case, one way to do away with SLP, or, if you don’t like to wait for ConsoleOne to browse for the eDirectory server, is to create a file hosts.nds inside /etc directory. This file is very similar to the hosts file that network engineers are so familiar with. The contents of our hosts.nds file are shown below:
# hosts.nds file for Virago
# Tree name Internet Address
Plasmon. 192.168.123.33

Note the trailing period “.” after the Tree name. This is not a typo — you need to specify it as a fully qualified tree name. If your server has a static IP address, you can specify it under “Internet Address”.
6.Configuring for LDAP With ConsoleOne
run ConsoleOne:

# cd /usr/ConsoleOne/bin
# ./ConsoleOne
ConsoleOne was not found in ./../jre/jre/bin/java

Later, I modified the /usr/ConsoleOne/bin/ConsoleOne script, add chmod line:

prog=”${jre}/bin/java”
chmod 777 “$prog” # grant privilege

# Run.
if [ -x “$prog” ]
then
$prog -noverify -Dapplication.home=”${APPHOME}” -classpath “$classpath” com.novell.application.console.shell.Console “$@”
else
echo >&2 “$progname was not found in ${prog}”
exit 1
fi

Then, run Console successfully.

7. Test LDAP server

After authenticating successfully, expand all the objects in the left pane and take a look around. Click on the oganization object in the left pane and you should see all the objects that are created for it in the right pane.

Locate the LDAP Server object and the LDAP Group object. You are going to make some changes to the properties of these objects. Right-click the LDAP Server object and select “Properties”. You will see the General Settings of your LDAP server.

Click on the SSL/TLS Configuration tab. Ensure that the checkbox for “Require TLS for All Operations” is cleared. Click Apply then Close.

Next, locate the LDAP Group object. Right click it and select “Properties”. You will see the LDAP Group General Settings. Ensure that the checkbox for “Require TLS for simple binds with password” is cleared. Click Apply then Close.

Now begin testing several LDAP operations against eDirectory.Using eDirectory’s text commands, which are very similar to those of OpenLDAP, and we will look at debugging information from DSTRACE, a very useful troubleshooting tool for eDirectory.

First, login as root, because cannot execute ndstrace as a normal user. Open a terminal window and execute the following command :
# ndstrace

The terminal window will look something like the picture above. Note the NDSTrace: prompt at the bottom of the window. Your commands will appear there. Type “set dstrace=nodebug” (without the quotes), this will clear the DSTRACE settings. Then type “set dstrace=+ldap”. This will turn on LDAP debugging. When you run any LDAP commands against this eDirectory server, informational and error messages will be displayed in this DSTRACE window. For production deployments, you will want to turn off LDAP debugging because it takes up CPU cycles.

At this point, issue the following command:
# ldapsearch -x -h localhost -b “” -s one objectclass=*
First time, I forgot to type “-x”, error displays: ldap_sasl_interactive_bind_s: Unknown authentication method”.
Add “-x”, all the entries are able to be returned.

Since 192.168.123.33 is the nds server IP address, I run the following commands on 192.168.123.33:
# ldapsearch -x -b “o=Plasmon” -H ldap://192.168.123.33
# ldapsearch -x -b “o=Plasmon” -H ldaps://192.168.123.33:636
# ldapsearch -x -b “o=Plasmon” -H ldap://127.0.0.1
# ldapsearch -x -b “o=Plasmon” -H ldaps://127.0.0.1:636
The above four run OK. But, when I log on other Linux(192.168.123.68), and try:
# ldapsearch -x -b “o=Plasmon” -H ldap://192.168.123.33
It always said cannot find LDAP server. Why? I check the ConsoleOne LDAP setting, its network configuration contains “ldap://127.0.0.1:389 ldaps://127.0.0.1:636”, and I could not modify this field. Is the disable connection caused by this setting? I scan all the open ports in 192.168.123.33, all LDAP ports display. Then run nmap in 192.168.123.68, Ah, it takes a long time to scan, but return no result. Yes, I see, The reason must be the firewall enabled in 192.168.123.33 server. Just shutdown the firewall in 192.168.123.33, and run ldapsearch again, Yeah!

分类: 科技 标签:

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

2006年12月11日 没有评论

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日 没有评论

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日 没有评论

#! /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日 没有评论

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日 没有评论

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日 没有评论

# $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日 没有评论

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日 没有评论

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.

分类: 科技 标签: