SCENARIO:
I will be FTP'ing a file to a remote server then running an FTP Script on the destination server remotely. Can I achieve this via FTP and the "quote" command, anyone got experience using this?
FTP Script (untested as I can't FTP the files freely..live environment)
open Server
user username password
cd destination directory
lcd source directory
put file renamedasthis
quote ksh /thisdirectory/autotrans /thiscript/ftpthefilesomewhere
close
bye
Whilst I am assuming quote can handle this, is there a better/different way of executing the remote FTP script (easy way)?
Unless the remote FTP server supports a ksh subcommand, the ftp quote subcommand cannot be used for this purpose.
The purpose of the quote subcommand is to bypass the FTP interface of your local host. It is typically used to send commands that the remote FTP server understands, but that the local FTP client does not understand.
I think the remote server does support the ksh commands..because i took the command from that server (i just need to execute it remotely).
I just wanted to make sure FTP could execute the script and it wasn't limited to just unix commands (like chmod or user etc)??? (another ftp script in this case).
I think you are mistaken.
The ftp command only responds to ftp commands.
As others advise, the "site" command is for local non-standard commands (see "man ftpd" on the target computer).
What Operating Systems and Shell (with versions) do you have on the source and destination computer?
Do you have administrator access to both computers?
Source Server = Solaris 10
Destination Server = Solaris 9
I have root access to both servers.
I will be transferring 1 file from to destination from source, then I need to move that file from the destination to another windows server (FTP already in place for that part, that is why I would like to remotely activate that script)
As you are using plain FTP between the servers, I assume that you trust the network to handle unencryted traffic. Could you consider a command to follow the FTP code you have written to put the file to issue a remote shell command to the destination?
#!/bin/ksh
#
ftp -n <<-EOFTP
open $destination
user bob password
cd $target_dir
put $file $targetfile
quit
EOFTP
rsh $destination "$shell_command with parameters"
You will need to open up the destination to accept the remote shell command, but if that is the way to go, we can talk about that later.
Many here will probably suggest that SFTP is a better method, and with that you would SSH remotely run the command, but I cannot comment on how to set that up.
I'd suggest looking into ftp's "proxy" command - Sun's "ftp" does support 'proxy':
proxy ftp-command
Executes an FTP command on a secondary control connec-
tion. This command allows simultaneous connection to
two remote FTP servers for transferring files between
the two servers. The first proxy command should be an
open, to establish the secondary control connection.
Enter the command proxy ? to see other FTP commands
executable on the secondary connection.
Something along these lines....:
( cat <<-EOF
open ${FirstHop}
user ${USRfirsthop} ${PASSWDfirsthop}
proxy open ${SecondHop}
proxy user ${USRsecondhop} ${PASSWDsecondhop}
put File2firsthop
proxy put File2firsthop
EOF
) | ftp -n -d -v
So "ftp quote" will definately not work and "ftp proxy" is a better choice. From the man pages it seems to do the right stuff. Unfortunately for me it seems I will need to create the scripts from scratch...there is a lot to dowithout any testing yet and only 2 days...
EDIT - it is plain FTP, internal network (basically)
does the proxy connection act as an ftp connection from the destination server?
It is refusing the connection (timing out), this can only be the case if the connection is coming from my server. The destination server (i know for a fact) has correct connections to the various other servers.
You're trying to push a file from A to C via B. Correct?
And your 'proxy' connection between B and C (when initiated from A) times out. Correct?
Can you ftp from B to C? Not as a 'proxy', but directly?
Login (telnet/ssh) to B and ftp to C? What happens?
I can telnet to B and FTP to C (yes I can directly FTP from B to C), at least connection is fine, I didn't actually move any files.
Commands I am trying, from my source server (A):
ftp serverB
user blahblah
password blahblah
proxy open serverB
As it fails, i don't do anything else. If I use IP Address it just sites there, if I use the DNS name it returns "Unknown Host: or invalid literal address".
In this case the ftpd on B is not configured to be used an 'ftp proxy' - I don't know what's missing.
I could 'ftp proxy' between 3 Solaris boxes in my lab and have been using this 'trick' on a couple of projects.
Sorry, I guess the 'proxy' is out the window - unless somebody knows the culprit....
not working, I attempted a different IP address in a range specifed for my firewall, it worked. When I tried the ip address which was specified for server B (and C's) firewall it fails...its a networking issue which is causing this to fail.
I need to try and get rsh working - Can anyone give me examples of how to use this, specifically from command line for testing then I can implement into a script like the kind user showed. Will rsh be able to execute an FTP script - "ftpscript1" as a normal user would?
i appreciate your help btw
---------- Post updated at 10:59 AM ---------- Previous update was at 09:06 AM ----------
going to ignore ftp now.
ssh access seems the most likely or a cronjob (can someone help with a script)..also ssh always prompts for password -need to avoid that.