1834157 Members
2885 Online
110064 Solutions
New Discussion

FTP question

 
SOLVED
Go to solution
Etienne Roseau
Frequent Advisor

FTP question

hi everybody !

i just want to do a "ls" in a specific directory with a small script (see attached).
my problem :
i'm succeedding in doing this "ftp", this "cd" and this "ls" by line command; but with the script...the "ls" is listing my $HOME, and i don't understand why.
i'm sure answer is obvious but i need some help to understand it.
thx in advance.
E.
5 REPLIES 5
Steven E. Protter
Exalted Contributor

Re: FTP question

The home directory is where you log on by default after making a ftp connection.

The ls is probably showing the home directory only because its not configured correctly and you have a chroot environment which restricts you to your home directory.

If you are the systems administrator, you need to check where you copied the ls binary. If not, you need to contact systems administration on this issue.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
harry d brown jr
Honored Contributor

Re: FTP question

Change your script to this format:


#!/usr/bin/ksh
export LOG=$HOME/test_ftp.log
ftp -v -n -i MACHINENAME << EOF | tee -a $LOG
user USERNAME USERPASSWD
cd /SOMEDIRECTORY
ls
quit
EOF

live free or die
harry d brown jr
Live Free or Die
harry d brown jr
Honored Contributor
Solution

Re: FTP question


Your original script was NOT going into FTP and executing the "ls" or the "cd" in ftp mode, thus it was purely local to your current session. Use the EOF method to "feed" input into FTP.

live free or die
harry d brown jr
Live Free or Die
Etienne Roseau
Frequent Advisor

Re: FTP question

thx for replying,
i'll check now, understanding most of my script failure.
Etienne Roseau
Frequent Advisor

Re: FTP question

okay, it's working much better now !!