Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 860
  • Last Modified:

ftp commands

running ftp from winNT/2000(client) to SCO 3.2(server).
Is it possible to execute a batch on the server via an ftp command?
We are trying out a graphical source code editor (SlickEdit) to work on our UNIX code.  The editor has a built in FTP client to access the code.  It also has FTP command line ability.  We would like to use the ftp command line to run batches on the SCO box.  Is this possible?
Thank You.
0
marvinm
Asked:
marvinm
  • 7
  • 3
  • 2
  • +3
1 Solution
 
tfewsterCommented:
Yep, no problem: At the ftp prompt (on in a script), use !command to run
a command
0
 
marvinmAuthor Commented:
I get an error 500 - command not understood for everything I try.  Do I need to prefix the command with something?  I am VERY unfamiliar with FTP.  Does the command get executed with the profile of the user I am connected as?
At the command line I try (as just one example):
! chown usr2 /usr2/myfile.c

Any suggestions?
Thank You
0
 
tfewsterCommented:
OK, you can fire up ftp interactively  - just type ftp at the NT command prompt:

Interactively:
ftp> open host_name
Connected to host_name
220 host_name FTP server (UNIX) ready.
Name (host_name:NT_user_name): Unix_user_name
331 Password required for Unix_user_name.
Password: My_password
230 User Unix_user_name logged in.
ftp>! chown usr2 /usr2/myfile.c
 .
 .
 .
ftp>quit

ftp has some "standard" Unix commands, e.g. cd and ls, plus the file transfer comands, e.g. put and get. man ftp on your SCO box will give you more.

To script this, and run it with ftp -s:script_name host_name, the script just needs to contain:
Unix_user_name
My_password
!chown user2 /usr2/myfile.c

It will close the ftp connection when the script finishes



0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
marvinmAuthor Commented:
This is my output:
ftp> ! chown usr2 /usr2/myfile.c
'chown' is not recognized as an internal or external command,
operable program or batch file.
ftp>

Is this possibly a limitation with my unix ftp server/setup?
Thank You.

looking at man pages for ftp, doesn't '!' try to run the command on the local machine instead of on the remote machine?
0
 
tfewsterCommented:
Sorry marvinm, I was talking complete rubbish: !command runs a command locally, i.e. on NT, not the SCO box

I don't think FTP will let you run remote commands, for security: You'd have to do it using rsh
0
 
chris_calabreseCommented:
You can't do this through FTP.

Your best bet is to telnet into the box and run the script.

Also, instead of FTP, you might want to try running SAMBA (www.samba.org) on your Unix boxen and then mount them like there were an NT server.
0
 
ahoorCommented:
marvinm

I think you can using the -n option.

create a file on your windows machine which includes

open [unixmachine]
user [login] [password]
cd [unix directory]
lcd [windows directory]
[ftp commands like get or send]

I you run this from the startmenu  ftp -n [filename] I think it will work.
I can't test it here but I will at work.

Disadvatntages are that:
1. the file includes a hardcoded, visible password
2. you can only do the coded file transfer ( I mean you have to code the
path- and filenames in the file, not flexible).

Hope this helps...
Arjan

0
 
ahoorCommented:
Oh, wait, forget my remark, that's not your question.

You want to use the ftp prompt as a unix prompt...
I think the only way may be if you ftp a file to a directory which is read
by a directory scanner which executes the file right after transfer.
0
 
dgrimesCommented:
marvinm

In your question, you state that the editor has a built-in ftp client. Does this mean that the editor will ftp to the server to get a file for editing and then save the file after editing using ftp put? I guess what I am asking is: what type of batch files do you need to execute and are the in any way related to editing files through SlicEdit?

Thanks



0
 
marvinmAuthor Commented:
Yes, the editor gets/saves the file with FTP.  The batches are for checking in/out files on server, and for compiling modules and programs (on indiviual user's accounts and final release account).
0
 
marvinmAuthor Commented:
We currently operate by keeping a telnet client open to the server to run the batches.  This is not a huge problem, but would be nice to eliminate the extra step.
0
 
dgrimesCommented:
Does each user have their own area to work from or is everyone sharing one area? Do the users need root privilages in order to accomplish their tasks? How much of a load is your system currently servicing? Do you have anyone with unix shell scripting abilities available to you?

There is a way to do what you want but it will take some scripting. You could create a daemon that looks for commands to execute in the form of batch files put into specific directories. Or instead of batch files you could use a file naming scheme that is parsed by the daemon. The file names themselves could act as commands to execute certian batch files.

I don't know if this is really going to buy you much though, as it still involves getting the commands to the unix server. But if you could automate putting the commands to the unix server through the FTP client within SlickEdit or somehow from SlickEdit FTP the commands direct, this will eliminate the need to exit SlickEdit, run telnet, execute the batch and wait for the results. You could even have the daemon email the results to you to let you know it was done processing your command.

Hope this helps,

Dean
0
 
marvinmAuthor Commented:
We have a daemon running already for our client/server app.  I tied into that, and many commands work fine.  The last issue I have is our check out batch.  It does something like the following:
if (test -r $HOME/src/$1.c) then
  echo "File Already in Directory"
  exit
fi
This test is always coming back successful when run through our daemon.
The $HOME and $1 are correct.  This is how I am running the check out:
su - myuser -c " checkout myfile " 
The daemon is running as root.

Any suggestions?
0
 
marvinmAuthor Commented:
My problem was that at the start of our daemon we were doing:
   struct sigaction act;

   act.sa_handler = SIG_IGN;    /** ignore death of child **/
   act.sa_flags = SA_NOCLDWAIT; /** do not create zombie processes **/
   sigaction(SIGCLD,&act,NULL); /** set the values **/


Before my system() call I needed to do:
   act.sa_handler = SIG_DFL;     /** return to default signal handling **/
   act.sa_flags = SA_RESETHAND;
   sigaction(SIGCLD,&act,NULL);
0
 
GP1628Commented:
run a "no hangup" batch which will watch for the script and then run it.

to avoid running the script while its still uploading always upload 2 files. The script and then an empty file named  go.txt
have the batch (or a scheduled job) watch for the go.txt

if go.txt
  run script
  delete go.txt
return to watching for go.txt
0
 
marvinmAuthor Commented:
I am accepting this comment as an answer since it closest the method that we are now using.  Thanks to all for their input. - mm
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 7
  • 3
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now