Solved

ftp commands

Posted on 2000-02-25
16
797 Views
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.
0
Comment
Question by:marvinm
  • 7
  • 3
  • 2
  • +3
16 Comments
 
LVL 20

Expert Comment

by:tfewster
ID: 2558148
Yep, no problem: At the ftp prompt (on in a script), use !command to run
a command
0
 
LVL 1

Author Comment

by:marvinm
ID: 2558219
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
 
LVL 20

Expert Comment

by:tfewster
ID: 2558410
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
 
LVL 1

Author Comment

by:marvinm
ID: 2558496
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
 
LVL 20

Expert Comment

by:tfewster
ID: 2558574
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
 
LVL 14

Expert Comment

by:chris_calabrese
ID: 2558765
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
 
LVL 3

Expert Comment

by:ahoor
ID: 2563304
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
 
LVL 3

Expert Comment

by:ahoor
ID: 2563315
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 2

Expert Comment

by:dgrimes
ID: 2565635
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
 
LVL 1

Author Comment

by:marvinm
ID: 2565665
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
 
LVL 1

Author Comment

by:marvinm
ID: 2565682
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
 
LVL 2

Accepted Solution

by:
dgrimes earned 200 total points
ID: 2565790
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
 
LVL 1

Author Comment

by:marvinm
ID: 2569575
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
 
LVL 1

Author Comment

by:marvinm
ID: 2570558
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
 
LVL 2

Expert Comment

by:GP1628
ID: 2580888
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
 
LVL 1

Author Comment

by:marvinm
ID: 2581188
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
sudo logging 5 68
Shell script errors 10 99
FTP on FreeBSD server 2 93
Write an app 10 61
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now