Execute Unix command using C#

J

Joseph

Hi,
I am trying to develop a C# application that will run
on Windows that will do the following
* Select file name to process
* FTP the file to a UNIX server
* Process this file on UNIX using a program on UNIX
"./pgmname -options Infilename > OutputFilename"
* FTP the output of this program back to Windows
* Process the resultant file and create output report file

I am not sure about how to execute the Unix command and
wait for the execution to be complete... Could someone
help me out here?

For the FTP, I plan to use the following... Is this ok?
Ftp ftp = new Ftp();
ftp.Connect (hostname);
ftp.Login (username, password);
// set transfer type to binary
ftp.SetTransferType (FtpTransferType.Binary);
// download file and display number of bytes transferred
long bytes = ftp.GetFile (remotePath, localPath);
Console.WriteLine ("Transfered {0} bytes.", bytes);
// disconnect
ftp.Disconnect();


Thanks
- Joseph
 
M

memememe

there is a few ways to execute remote commands on a unix machine, since you
are using ftp then I figure its a fairly unsecure box, so telnet or some
other remote command execution technology. You could use SSH for a little
added security, im sure there is alreayd some sort of telnet or SSH API on
..net or at least sample code, telnet would be extremely easy to pull off.
Alternatively you could make a webpage on the unix system that executes that
program and call that webpage from c#.
 
J

Joseph

Greg,
Currently, we do a manual process where we..
1. FTP the file to be processed to the UNIX machine
2. Execute the statement on the UNIX machine (using Telnet)
"./pgmname -options Infilename > OutputFilename"
3. FTP the outputfile back to local machine
4. Process the resultant file and create output report file

- Joseph
 
J

Joseph

Oh wow... I didn't realize this was gonna be so
complicated - I guess I was hoping for something simple
like the way FTP is implemented... I guess I will have to
think up some other way...
Thanks for your help though Greg - and most of all, thank
you for the link! It has a LOT of useful info!

- Joseph
 
M

memememe

I just had a different idea.
Why not write a little shell script on the unix machine that monitors when
that file you are ftping is changed and then it executes the process?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top