Friday, April 06, 2007

Dev : FTP-ing In Windows Using Script

Have you ever using FTP in Windows? Commands are almost similar with Unix. You may have use Unix Shell script, but have you tried using Windows batch file to help you do the job, for example, getting some log files from a Unix Webserver, without the hassle of typing repeating ftp commands?

There are 2 method.

Method 1:
Create 2 files. 1 is a text file (ftp_cmd.txt) , another is a batch file (ftp_cmd.bat).

ftp_cmd.txt


FTPuserLogin
FTPuserPassword
cd /user/define/location
mget userlogfile.log
y
bye



ftp_cmd.bat


@echo off
ftp -s:ftp_cmd.txt serverhostname



Method 2:
Create 1 batch file (ftp_cmd.bat).

ftp_cmd.bat


@echo off

echo FTPuserLogin> ftp_cmd.txt
echo FTPuserPassword>> ftp_cmd.txt
echo cd /user/define/location>> ftp_cmd.txt
echo mget userlogfile.log>> ftp_cmd.txt
echo y>> ftp_cmd.txt
echo bye>> ftp_cmd.txt

ftp -s:ftp_cmd.txt serverhostname

del ftp_cmd.txt



Please take note that the batch file cannot be named as ftp.bat. This will cause confusion between your batch file and ftp command and it will keep on displaying a loop. Every details must not end with a white space.

Monday, April 02, 2007

Dev : Adding New User

In Solaris, adding user is not as 'too' simple as in Linux.

When we use "useradd -d /home/unixuser unixuser" in Linux, we will be automatically create a user called unixuser and a new directory call /home/unixuser will be created.

However, in Solaris, "useradd -d /home/unixuser unixuser" will only create a user call unixuser, but no user home directory will be created. To make it easy, just add in an extra parameter called "-m", as in create home directory. So the better command for created user in Solaris should be "useradd -d /home/unixuser -m unixuser".

For more information on unix useradd, see here.