Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP Help 2

Status
Not open for further replies.

alberton

Technical User
Feb 26, 2003
250
ES
Hi,

I´m not an experteese of solaris programation.
I will appreciate if someone can help me creating a script which put some solaris system files in a Windows directory through ftp protocol, and then repeat the operation every 10 minutes.

I've tryed this one but doesn't work:

ftp -n 129.200.100.120 <<END_SCRIPT
quote USER beto
quote PASS *******
cd /cms/cmstables
bin
put 'chr*'
quit
END_SCRIPT
exit 0

Thanks in advance.
 
If you are going to specify filenames using a wildcard you need to use mput, not put. You may also need to use the prompt command before it to turn off the prompt confirming which files to transfer.

Annihilannic.
 
Would it be something like this:

ftp -n 129.200.100.120 <<END_SCRIPT
quote USER beto
quote PASS *******
cd /cms/cmstables
bin
prompt
mput 'chr*'
quit
END_SCRIPT
exit 0

How I can execute this script to check it? I mean is there a command to execute this script?
Thanks
 
The 'command' is what you called it, as long as you've made it executable (chmod 755 filename).

Some days are diamonds, some days are rocks - make sure most are the former.
 
Thanks for the answers.
And how I do to repeat the process every 10 minutes?
Regards
 
You can put it in 'cron' (man crontab or look for examples), but basically something like:

00,10,20,30,40,50 * * * * /path/to/command script

would call the script every 10 minotes 24/7 if that's what you want. Bear in mind that you may have to supply the appropriate environment to cron (PATH etc) and/or use fully qualified pathnames in the script itself so that cron 'knows' where to look for things.

An alternative might be to put a sleep 600 in your script and loop back to the start of the script afterwards, but this has the disadvantage that it will not restart after a shut down unless you put it in a startup directory such as /etc/rc2.d or start it explicitly on reboot.

Some days are diamonds, some days are rocks - make sure most are the former.
 
Thank you very much for the answer.
I will try as soon as possible and I'll post the result.
Thank you guys.
 
Hi,

I have created a file with the above sintax and then made a chmod 755 but it doesn't do anything or at least the file is not transfered.
I do the steps manually and it works.
Any clue about what am I doing wrong?
 
...did you include explicit environment variables as I suggested?

Some days are diamonds, some days are rocks - make sure most are the former.
 
KenCunningham, I added the variable names, but even it do not make the ftp connection.
It receive this message:
129.200.100.104: bad port number-- SCRIPT
usage: ftp host-name [port]
Not connected
Not connected
?Invalid command
Not connected
Interactive mode off
Not connected

My SCRIPT is this one:

HOST='129.200.100.104 21'
USER='macbeto'
PASSWD='******'
FILE='/'



ftp $HOST <<END SCRIPT
quote USER $USER
quote PASS $PASSWD
$FILE
bin
prompt
mput "beto.*"
quit
END SCRIPT
exit 0


The crontab -l show my line cron:
00,10,20,30,40,50 * * * * /beto1

What I see is the script stops just in the ftp connection, but I do the same command manually and it connects right.
Thanks for the answers.
 
When you use here documents, i.e. << SOME_TAG, it needs to be only one word. You could make it END_SCRIPT instead of END SCRIPT.

Annihilannic.
 
Thank you Annihilannic,

That was the problem.
Regards
 
Good spot Annihilannic! Worthy of a star perhaps alberton?

Some days are diamonds, some days are rocks - make sure most are the former.
 
Of course it is worthy for me. I didn't know about the stars.

Thank you.
 
Here is what I use to move files to a WINXP system

ip=000.000.000.00
USER=admin
PASSWD=ramsey
ftp -d -n -i -v $ip <<SCRIPT
user $USER $PASSWD
lcd /$ric
cd $ric
bin
hash
mput xxxxxx.*"
quit
SCRIPT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top