We help IT Professionals succeed at work.

ftp commands

marvinm asked
Last Modified: 2010-04-21
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.
Watch Question

Yep, no problem: At the ftp prompt (on in a script), use !command to run
a command


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

OK, you can fire up ftp interactively  - just type ftp at the NT command prompt:

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 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:
!chown user2 /usr2/myfile.c

It will close the ftp connection when the script finishes


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.

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?

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
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.


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...

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.


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?



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).


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.
This one is on us!
(Get your first solution completely free - no credit card required)


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"
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?


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;

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


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

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.