LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Solaris / OpenSolaris (http://www.linuxquestions.org/questions/solaris-opensolaris-20/)
-   -   Using FTP to execute command line commands remotely (http://www.linuxquestions.org/questions/solaris-opensolaris-20/using-ftp-to-execute-command-line-commands-remotely-144329/)

steve_2010 02-10-2004 01:56 AM

Using FTP to execute command line commands remotely
 
:newbie:
Hi all!
I know nuts about unix programming so pls dun laugh ur head off or tear off ur hairs at my questions. :)

Pls have a look at my Bourne Shell Script:

#!/sbin/sh

ftp remotehost << StartOfFtp
user root root
cd /opt/user
/*
There are two remote folders path (/opt/user & /data) which I will access and both contains data files (.log). /data folder will continuously add in new .log files. So what this section will do is to compare the data files in /data folder with the data files in the /opt/user. For data files that exists in /opt/user will not be copied over while data files that does not exists in /opt/user will be copied over and renamed (What I mean the filename will be appended adding a LBS_ in the front). Then I will then ftp the data files which does not exists in /opt/user to the local folder path /tomcat/webapps/chart/data
*/
ls >> /result
StartOfFtp
su user << StartUser
user
crontab /opt/user/cronjob
exit
StartUser

1) Is my coding correct so far? ok exclude the /* */(Sorry I am now learning java so pls excuse me)
2)I am stuck as how to continue the section explained in the /* */. Can anyone give me an example script and an explaination? I am really at my wits end and is starting to tear my hair apart trying to search for examples in the google.

stickman 02-10-2004 07:55 AM

The Solaris FTP server doesn't allow access to su, crontab or most other commands. Connect with the client and issue the help command to see what is available. You're probably better off going SSH route for this type of stuff.

steve_2010 02-10-2004 07:07 PM

Ok stickman thank you for your advice guess have to see again what SSH has to offer...............

steve_2010 02-10-2004 07:13 PM

One last question what is the ftp "exec" command does? I am sorry but I just can't understand what it means......... Can anyone care to explain it to me in plain english pls?


Steve Tan
Solaris and Java Newbie

stickman 02-13-2004 08:44 AM

exec is shell command that allows you to replace the current shell with another shell or comman. For example, if your normal default login shell in Solaris is sh, but you want to run ksh, you could do either of these commands to get to ksh:

ksh
exec ksh

The first will run ksh "on top of" your current sh. It will take two exits to logout.
The second will replace your sh with a ksh. It will take one exit to logout.

You also see this when working with window manager where the last line of the script is an exec statement. This will replace the shell with the window manager, and when the manager is exited the user is also logged out. exec also works in Linux.


All times are GMT -5. The time now is 11:19 AM.