![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| passing a variables value from the called script to calling script using ksh | rajarkumar | Shell Programming and Scripting | 10 | 12-23-2008 02:51 AM |
| Include PERL script with in the unix shell script | ganapati | UNIX for Dummies Questions & Answers | 1 | 04-29-2008 01:18 PM |
| help me in sending parameters from sqlplus script to unix shell script | Hara | Shell Programming and Scripting | 2 | 01-29-2008 03:31 PM |
| Shell Script: want to insert values in database when update script runs | ring | Shell Programming and Scripting | 1 | 10-25-2007 04:06 AM |
| here document to automate perl script that call script | hogger84 | Shell Programming and Scripting | 3 | 10-22-2007 11:15 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
A ftp script
Hi guys I'm writing my first shell script and I can't get rid of some errors. First of all my shell is ash. I've written the following script with the goal to log in on FTP server and calculate the throughput like number bytes transmitted (returned by get) /time for transmitting them. The error tha I get when I execute my shell are: Unresolved host -n ftp>quote USER di leo memory fault core dumped Thank you in advance. Code:
#!/bin/sh HOST='10.0.0.201' USER= 'dragon' PASSWD= 'dragon' FILE='/home/dragon/minix_modified/lance.c' START=$(date+%s) ftp -n $HOST <<END_SCRIPT quote USER $USER quote PASS $PASSWD get $FILE >> NUMBYTES END=$(date+%s) DIFF=$(($END-$START)) THROUGHPUT= NUMBYTES/DIFF quit END_SCRIPT exit 0 |
|
||||
|
Check the value of $HOST
Firstly, I don't think your calculation should be done inside ftp. Secondly, I am not sure about "get $FILE >> NUMBYTES", whether it will work or not. Finally and most importantly, Please enable debugging using set -x and copy/paste its output for better troubleshooting. Code:
#!/bin/sh set -x HOST='10.0.0.201' USER= 'dragon' PASSWD= 'dragon' FILE='/home/dragon/minix_modified/lance.c' START=$(date+%s) ftp -n $HOST <<END_SCRIPT quote USER $USER quote PASS $PASSWD get $FILE >> NUMBYTES quit END_SCRIPT END=$(date+%s) DIFF=$(($END-$START)) THROUGHPUT= NUMBYTES/DIFF exit 0 set +x Note: I hope you understand what the meaning of first line "#!/bin/sh ". |
|
||||
|
First of all thank you for your help. Second I think I know the meaning of first line "#!/bin/sh, it should point out which interpreter use for your script. To be more precise "#!" is a magic number of two bytes to identify a file or script like in this case. I'm learning script programming so I could have made some mistakes in this definition. Any way I applied your corrections and this is the output (Note: to log in I don't need a password so I set PASSWORD='' and the ftp server is a windows workstation Code:
+HOST=192.168.1.6 +USER=domenik domenik: No such file or directory +PASSWD= :Permission denied +FILE=/minix/minix_modified/lance.c +date%s date+%s: No such file or directory +START +ftp -n 192.168.1.6 Memory fault - core dumped +date%s date+%s: no such file or directory +END= +- -:No such file or directory +DIFF= +THROUGHPUT=NUMBYTES/DIFF ./ftp.sh:NUMBYTES/DIFF No such file or directory +exit 0 |
|
||||
|
Thanks psiva_arul Unfortunately I keep on receiving errors messages: Before I continue bore you, i think it's better how I access to the FTP server without script. The FTP server is mozzila on win xp 1 I type: ftp 192.168.1.6 and I'm in the directory "minix" 2 I type my username: domenik 3 I type: "the bottom return" because I don't need to write any password 4 I type: cd minix_modified 5 I type: get lance.txt 6 I type: quit After the "get" is displayed the bytes transferred that I'm interest to pick because I want to calculate the throughput Thank for your help The errors with your script are: Code:
+date%s date+%s: No such file or directory +START +ftp -n 192.168.1.6 Unresolved host -n ftp>user root You must "open" a connection first ftp>cd You must "open" a connection first ftp>lcd C\sample Couldnt not change local directory. No such file or directory ftp>get lance.c>>NUMBYTES You must "open" a connection first ftp>quit FTP done +date+%s date+%s: No such file or directory +END= +- -: No such file or directory +DIFF= +THROUGHPUT= NUMBYTES/DIFF ./ftp.sh: NUMBYTES/DIFF No such file or directory +exit 0 |
|
||||
|
FTP Script
Hi all,
In the below script to download file names with todays date from ftp, how can i delete the file downloaded from the ftp site after sucessfully downloading the same. I am using the below script however, its not deleting after download of the file. #!/bin/bash -vx now_date=`date +%d%m20%y` ftp -in 192.168.77.7<<END_SCRIPT quote USER abc quote PASS XXXX bin prompt off cd /PC65021001 --folder on ftp lcd /report/common/scripttesting/FTP_down --folder on local drive mget PC65021001-${now_date}-* mdel PC65021001-${now_date}-* bye END_SCRIPT |
![]() |
| Bookmarks |
| Tags |
| automated login, ftp |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|