How to run a shell script on a remote host using ftp

Hi,
is there a way I can run a shell script through ftp on a remote host? The remote host doesn't have ssh running so I can't use ssh.

Is telnet running on the remote host?

Perhaps something with
scheduled cron task
the task checks for the existence of a file
(this could be ftp'ed to the remote system)
then a script is executed

telnet is running, i just tried the following telnet script on it, it worked but there is code in my ksh script after the telnet commands, and that code doesn't execute, as if the script is unable to get out of telnet:

 
#!usr/bin/ksh
 
(sleep 2
echo user
sleep 1
echo pass
sleep 2
echo "/path/to/script.ksh"
sleep 1
echo "exit") | telnet host1
#program freezes here i think
 
#more code to execute

---------- Post updated at 11:21 AM ---------- Previous update was at 10:42 AM ----------

I don't have experience with cron but doesn't that just run a script at certain time intervals? I want to run the script whenever I prompt it to run.

You can run the watch command on the remote machine and while it is running the script will be executed. The script can be multiline:

Execute the script on the remote machine every 60 seconds

echo > mycommands.sh
watch -n60 "chmod +x timedcommand.sh && ./timedcommand.sh"

Remotely overwrite the mycommands.sh file via ftp.

You can upload an empty file to stop commands.

I'm not supposed to be running the script that often, is there a different way to do this? I also have remsh on the host. can remsh run scripts?

remsh requires Kerberos 5 authentication and requires that the local user ID is not the root user. You specified to use only ftp not remote shells.

The watch command has the disadvantage that if the computer reboots you lose the command. You can use any well known scheduler for that cases.

Check here at cron:

---------- Post updated at 11:22 AM ---------- Previous update was at 10:52 AM ----------

There is another way you can do it: test permanently on host if a certain file exists, and when it does run the command once.

So you re-upload the run.txt file again for each time you want to run mycommand and even you can change the command for the next time. If for some reason the command fails the file failed.txt will be generated and you can see it from ftp.

On host:

echo "my command" > mycommand.sh
watch -n10 "if test -e run.txt ; then chmod +x mycommand.sh && ./mycommand.sh && rm run.txt || rm run.txt && echo > failed.txt ; fi"

-------------
Remote:

 ftp put run.txt run.txt

OR
Local:

echo > run.txt

I did it with remsh, thanks for the help though.