Shell Program , need help!!

Hi all,

I am trying to get a file from an ftp server and i have the list of files which needs to be get from the ftp server.

grep unix_prg*.* log.txt > log1.txt

log1.txt (which has the list of files)

06-29-09 00:00AM 3550258 unix_prg090629
06-28-09 07:00PM 115733 unix_prg090628
06-27-09 07:02AM 1025004 unix_prg090627
06-26-09 07:12PM 5399554 unix_prg090626
06-25-09 07:09PM 4111899 unix_prg090625
06-24-09 07:05PM 2012520 unix_prg090624
06-23-09 07:07PM 2950387 unix_prg090623
06-22-09 07:09PM 4080367 unix_prg090622
06-21-09 07:01PM 322285 unix_prg090621

if i am using the command head -1 log1.txt > log2.txt

log2.txt (output file)

06-29-09 00:00AM 3550258 unix_prg090629

i got the exact file which i need to take it from ftp server.

How can i invoke the same , i need a way to get the file from that server ??

Just need to login to the ftp server and get the file which is printed in log2.txt

Thanks!!

You may like to try FTP yourself first...
Read here first.

Thankyou!! i have tried couple of times, not able to get the condition which i need,

Can anyone help me on this ??

Thanks!

Hi, Can u show the script u r using to ftp the file? What issue u r facing exactly?

ftp -nv $HOST > log.txt << END_SCRIPT
   quote USER $USER_show
   quote PASS $PASSWD_show1
cd unix1
   ls -ltr
quit
exit 0
grep unix_prg*.* log.txt > log1.txt 
head -1 log1.txt > log2.txt 

log1.txt (which has the list of files)

06-29-09  00:00AM              3550258 unix_prg090629
06-28-09  07:00PM               115733 unix_prg090628
06-27-09  07:02AM              1025004 unix_prg090627
06-26-09  07:12PM              5399554 unix_prg090626
06-25-09  07:09PM              4111899 unix_prg090625
06-24-09  07:05PM              2012520 unix_prg090624
06-23-09  07:07PM              2950387 unix_prg090623
06-22-09  07:09PM              4080367 unix_prg090622
06-21-09  07:01PM               322285 unix_prg090621

log2.txt (output file)

06-29-09  00:00AM              3550258 unix_prg090629

i got the exact file which i need to take it from ftp server.

from here i am not sure how to get the file which is in log2.txt ??

thanks

This is the sample script to ftp a file.

 
HOST='host'
USER='yourid'
PASSWD='yourpw'
LOCAL_PATH='path'
REMOTE_PATH='remote_path'
FILE='filename'
ftp -n <<EOF
open $HOST
user $USER $PASSWD
cd $REMOTE_PATH
get $FILE $LOCAL_PATH
quit
EOF
exit 0

To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags

```text
 and 
```

by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums

Subsitute filename as below.

 
FILE=`awk -F " " '{print $4}' log2.txt`