Computing.Net > Forums > Unix > ftp help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

ftp help

Reply to Message Icon

Name: Jernand
Date: January 10, 2005 at 11:52:19 Pacific
OS: hp-ux
CPU/Ram: 1280mb
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: vgersh99
Date: January 10, 2005 at 12:12:45 Pacific
Reply:

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.


0

Response Number 2
Name: Jernand
Date: January 10, 2005 at 12:29:21 Pacific
Reply:

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


0

Response Number 3
Name: vgersh99
Date: January 10, 2005 at 12:31:24 Pacific
Reply:

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


0

Response Number 4
Name: Jernand
Date: January 10, 2005 at 12:37:59 Pacific
Reply:

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


0

Response Number 5
Name: Jernand
Date: January 10, 2005 at 12:41:03 Pacific
Reply:

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

Regards,
Jern


0

Related Posts

See More



Response Number 6
Name: vgersh99
Date: January 10, 2005 at 12:43:06 Pacific
Reply:

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 ]


0

Response Number 7
Name: Jernand
Date: January 10, 2005 at 12:48:21 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: ftp help

Unix/FTP help www.computing.net/answers/unix/unixftp-help/7195.html

ftp sql results in shell script www.computing.net/answers/unix/ftp-sql-results-in-shell-script/6338.html

invoke bat file from FTP Urgent! www.computing.net/answers/unix/invoke-bat-file-from-ftp-urgent/7088.html