Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I want to write a ftp script which does a listing of the remote directory from within ftp and send that to a file to me as an output to the script. Is this possible? please help..
Regards,
Jern

ftp -n remoteHost <<EOF
open remoteHost
user remoteUser remotePassword
ls path2remoteDir path2localFile2bStored
EOF
From 'man ftp':
ls [ remote-directory | -al ] [ local-file ]
Print an abbreviated listing of the contents of a
directory on the remote machine. If remote-
directory is left unspecified, the current working
directory is used.The -a option lists all entries, including those
that begin with a dot (.), which are normally not
listed. The -l option lists files in long format,
giving mode, number of links, owner, group, size
in bytes, and time of last modification for each
file. If the file is a special file, the size
field instead contains the major and minor device
numbers rather than a size. If the file is a sym-
bolic link, the filename is printed followed by
"->" and the pathname of the referenced file.If no local file is specified, or if local-file is
-, the output is sent to the terminal.

Hi,
I used the same script and ran it after creating a local file.
it just displays a message and does nothing.
i checked the local file but it has nothing.where am i going wrong?
Regards,
Jern

when you connect to the remote system and do 'ls' on the remote directory, what happens? Do you get a listing to stdout?

yes.. i do get the output of an "ls".
i removed the 2'nd line from the script..
and now i get this message./ftpsct
?Invalid command
output to local-file: /home/mydir/ftpfile?Regards,
Jern

I got it now..thanks for your help.. i was confused with the remote and the local directory..thanks again..
Regards,
Jern

removed the second line?
The line with user/password? You need that.You understand what the script does, don't you?
What OS is your local host running under?
Do 'man ftp' on the local host and search for the explanation/options of the 'ls' command.
As I saind in the original reply, on my system [Solaris], the syntax for 'ls' is:
ls [ remote-directory | -al ] [ local-file ]

the second line was
open remote host.. i thought i dont need that sice the first line "ftp -n remoteHost <<EOF" takes care of it.i am running on hp-ux.
i messed up with the local and remote host files.now its working..thank you :)
Regards,
Jern

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |