1834650 Members
2434 Online
110069 Solutions
New Discussion

Re: script with FTP

 
SOLVED
Go to solution
FOREST Michel
Frequent Advisor

script with FTP

how can execute a script with a connection ftp on the server HP ?
Thanks in advance
A rookie in the HP Forum :)
9 REPLIES 9
Dan Hetzel
Honored Contributor

Re: script with FTP

Hi Michel,

You may use what's called a 'here document' like this:
ftp << EOF
open HOSTNAME
LOGIN_NAME
PASSWORD
binary
cd /tmp
put FILE
bye
EOF

Replace HOSTNAME, LOGIN_NAME, PASSWORD and FILE with appropriate data.

A 'here document' is a way to simulate the keyboard entry with text data located between matching labels (EOF in the example above)

man sh-posix will explain this (do a search for <<)

Best regards,

Dan



Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com
Thomas J. Harrold
Trusted Contributor

Re: script with FTP

It is also worth noting that you can use variables in the above solution. (ie $DESTINATION, $USERNAME, etc...)

It makes this much more flexible when inserting into a script.

Best of luck.

-tjh
I learn something new everyday. (usually because I break something new everyday)
Roulet
Occasional Advisor

Re: script with FTP

Michel,

FTP is not really secure by this way,
have a look on this: see attached file

Happy new year

Pierre
;-))
FOREST Michel
Frequent Advisor

Re: script with FTP

thanks Dan, tjh, Pierre, for answers.
But i don't want use FTP in a script, I want execute a script on a connection FTP (ex: idem .profile for rlogin or telnet)

Thanks in advance.

MF
A rookie in the HP Forum :)
Dan Hetzel
Honored Contributor
Solution

Re: script with FTP

Hi Michel,

Your example (same .profile for rlogin and telnet) is impossible.
The reason is:
rlogin starts a shell while ftp doesn't.
As .profile is a shell executable, it cannot be used with non shell programs.

If you want to execute remote commands on a system, you could use 'remsh' to run any script or program, providing you're allowed to, and 'rcp' to copy files back and forth.

What do you want to do on the remote system?

Best regards,

Dan
Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com
FOREST Michel
Frequent Advisor

Re: script with FTP

Hi Dan,
ok with you. in fact, I want execute a process on server HP when a user 'toto' this connect in ftp

thanks Dan.
A rookie in the HP Forum :)
Steve Massey_1
Frequent Advisor

Re: script with FTP

Hi Michel

run ftpd -l this -l option should log to syslog the ftp connection and username.

Then have cron setup to grep for the said user/ftp in syslog and run the required script.

Hope it's of some help

Steve
Dan Hetzel
Honored Contributor

Re: script with FTP

Hi Michel,

Andreas Voss gave an example to redirect the logs to a different file. This would prevent syslog.log from becoming too large.

---QUOTE Andreas
this is not a single switch of ftpd messages but a solution that redirects ANY daemon facility (including ftpd) to a different file:
Change /etc/syslog.conf FROM:
mail.debug /var/adm/syslog/mail.log
*.info;mail.none /var/adm/syslog/syslog.log
*.alert /dev/console
*.alert root
*.emerg *
TO:
mail.debug /var/adm/syslog/mail.log
daemon.info;mail.none /var/adm/syslog/daemon.log
*.info;mail.none,daemon.none /var/adm/syslog/syslog.log
*.alert /dev/console
*.alert root
*.emerg *

(Note: delimiter MUST BE [TAB])
This will write daemon facilities into /var/adm/syslog/daemon.log.
After changes to /etc/syslog.conf reinitialize syslogd:
/sbin/init.d/syslogd stop
/sbin/init.d/syslogd start

---\QUOTE

Best regards,

Dan
Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com
FOREST Michel
Frequent Advisor

Re: script with FTP

thanks all and Happy New Year !!!

MF.
A rookie in the HP Forum :)