1834038 Members
2719 Online
110063 Solutions
New Discussion

Re: FTP remote exec.

 
Greg Stark_1
Frequent Advisor

FTP remote exec.

Is there any way to ftp to a UNIX box and kick-off a script via that ftp session?

Thanks again in advance,
Greg
7 REPLIES 7
Victor BERRIDGE
Honored Contributor

Re: FTP remote exec.

Hi,
As the meaning of ftp is.., what have you in mind?
if you were looking for a script to put/get etc.. the answer is you can write a script that uses .netrc to bypass ftp asking you your name and passwd, and - or in a script you can write: (example of logged seesion with get...)
# ftp_fda : test new ftp...
rm ftp.log
ftp -n > ftp.log << end
open hostsname
user scsf "passwd"
get scsf/fda/fda /export/f/fda
quit
end
if [ `wc -l ftp.log|cut -c 1` -gt 0 ]
then
# Output transfer error
echo " Transfer ERROR : FDA"
sleep 5
else
echo " FTP Transfer OK for FDA"
fi


Best regards
Victor
Patrick Wallek
Honored Contributor

Re: FTP remote exec.

This can be done, but it is a security risk.

The to do it is with the ! in ftp. The ! (exclmation point, bang) lets you execute a shell command.

# ftp localhost
Connected to localhost.
220 cruella FTP server (Version 1.7.212.4 Tue Sep 12 04:33:08 GMT 2000) ready.
Name (localhost:z93573):
331 Password required for z93573.
Password:
230 User z93573 logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> !/tmp/pww/test2
Greg Stark_1
Frequent Advisor

Re: FTP remote exec.

Patrick, your response seems to work great, but only if I ftp to the "localhost". My intension would be to start an ftp session from on nt server to the unix server and then run a script on the unix server.

For example, this would be ran from the nt server:

C:\>ftp unixbox
Connected to unixbox.com.
220 unixbox FTP server (Version 4.1 Sun Nov 19 22:15:05 CST 2000) ready.
User (unxibox.com:(none)): gstark
331 Password required for gstark.
Password:
230 User gstark logged in.
ftp> !/tmp/test.sh
The system cannot find the path specified.
ftp> done
?Invalid command
ftp> bye
221 Goodbye.

As you can see, it cannont find/execute the file remotely.
Thanks
Greg
Wieslaw Krajewski
Honored Contributor

Re: FTP remote exec.

Hi,

There is no possibility to run via ftp a script on the ftp server. See man page on ftpd to check all implemented ftp commands.
When during ftp session you use !command, this command is run locally on the ftp client.
If you ftp to the localhost, the same machine is the ftp client and the ftp server, and this explains your observation relating to the running script when being ftped to the localhost.

Rgds.
Permanent training makes master
Herve BRANGIER
Respected Contributor

Re: FTP remote exec.

Hi

In the standard it's file transfet only so you
can't. But a command can be accepted :
SITE. So you connect with your ftp client and
you can use SITE EXEC prg. It's seems to work
with HPUX11 box, but it's HPUX or non standard
commands !!!

For more information see man page of ftpd (it's
depend of your ftp server only).

HTH

Herv?

Volker Borowski
Honored Contributor

Re: FTP remote exec.

Hello,
this depends on the deamon in charge.

ftp> remote help

should give you a list, which commands the remote site accepts. Some provide EXEC just for compatibility reasons, but when you execute it like Herv? pointed out, it says "not implemented". So it depends on the server. Since this is a big security risk, some daemons require special config to activate this feature.

Volker
Volker Borowski
Honored Contributor

Re: FTP remote exec.

Just found something else:

http://forums.itrc.hp.com/cm/QuestionAnswer/1,1150,0xa2b3d06ed8c8d4118fef0090279cd0f9,00.html

Be carefull, the directories should not be writable by anyone, because then sombody might upload something not so good for you !

This will do it
Volker