473,386 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Execute Unix command using C#

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
Nov 15 '05 #1
6 16349
Joseph, how would you do this if you weren't programming it?

--
Greg Ewing [MVP]
http://www.citidc.com

"Joseph" <jo**********@nospam.com> wrote in message
news:2b****************************@phx.gbl...
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

Nov 15 '05 #2
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#.
"Joseph" <jo**********@nospam.com> wrote in message
news:2b****************************@phx.gbl...
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

Nov 15 '05 #3
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
-----Original Message-----
Joseph, how would you do this if you weren't programming it?
--
Greg Ewing [MVP]
http://www.citidc.com

"Joseph" <jo**********@nospam.com> wrote in message
news:2b****************************@phx.gbl...
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

.

Nov 15 '05 #4
Joseph, so what you need is a telnet client for C# right? You have a couple
of options, write your own, buy one, or download a free one. Here's a link
to some samples to get you started.

http://www.gotdotnet.com/community/u...x?query=telnet

--
Greg Ewing [MVP]
http://www.citidc.com
"Joseph" <jo**********@nospam.com> wrote in message
news:05****************************@phx.gbl...
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
-----Original Message-----
Joseph, how would you do this if you weren't programming

it?

--
Greg Ewing [MVP]
http://www.citidc.com

"Joseph" <jo**********@nospam.com> wrote in message
news:2b****************************@phx.gbl...
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

.

Nov 15 '05 #5
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
-----Original Message-----
Joseph, so what you need is a telnet client for C# right? You have a coupleof options, write your own, buy one, or download a free one. Here's a linkto some samples to get you started.

http://www.gotdotnet.com/community/u...les/Default.as px?query=telnet
--
Greg Ewing [MVP]
http://www.citidc.com
"Joseph" <jo**********@nospam.com> wrote in message
news:05****************************@phx.gbl...
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
>-----Original Message-----
>Joseph, how would you do this if you weren't programming
it?
>
>--
>Greg Ewing [MVP]
>http://www.citidc.com
>
>"Joseph" <jo**********@nospam.com> wrote in message
>news:2b****************************@phx.gbl...
>> 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
>
>
>.
>

.

Nov 15 '05 #6
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?
"Joseph" <jo**********@nospam.com> wrote in message
news:07****************************@phx.gbl...
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
-----Original Message-----
Joseph, so what you need is a telnet client for C#

right? You have a couple
of options, write your own, buy one, or download a free

one. Here's a link
to some samples to get you started.

http://www.gotdotnet.com/community/u...les/Default.as

px?query=telnet

--
Greg Ewing [MVP]
http://www.citidc.com
"Joseph" <jo**********@nospam.com> wrote in message
news:05****************************@phx.gbl...
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

>-----Original Message-----
>Joseph, how would you do this if you weren't programming it?
>
>--
>Greg Ewing [MVP]
>http://www.citidc.com
>
>"Joseph" <jo**********@nospam.com> wrote in message
>news:2b****************************@phx.gbl...
>> 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
>
>
>.
>

.

Nov 15 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Casanova | last post by:
Hello! How can I execute other exe files from within a executable file in GCC. In TurboC 3, the spawn command executes a file and returns command to the calling file. whereas in GCC, the exec...
14
by: technocrat | last post by:
db2 -t -v -f/home.../filename >output_file-name I have a java stored procedure..which has to run the above command...not sure how i can run this command through java.. any suggestions are...
7
by: spec | last post by:
Hi all, I know nothing about Python. What I need to do is to get a Python script to execute a local shell script. I do not need any output. What would be th eeasiest way to accomplish this? ...
9
by: sohan | last post by:
Hi, I want to know how to connect and execute a db2 query from inside a UNIX shell script. Details: We have a unix shell script. We need to execute multiple db2 sql queries from this shell...
2
by: wizardRahl | last post by:
Hello, I'm trying to install ArcInfo 9.2 (GIS software) on an Ultra 40 running Solaris 10 (x86). I am also extremely new to the unix environment. When I get to the correct path and try to run the...
7
by: sonet | last post by:
in perl we can execute command and get result(command line stdout) by $a=`cmdline parameter`; print $a; in c system('cmdline parameter'); but i can not get the result (command line stdout).
3
BenTheMan
by: BenTheMan | last post by:
Ok---I was wondering...Is there any way to make C++ execute a UNIX command? Like, I generate LaTeX files in my code, file.tex. Then I need to compile the .tex files with ``pdflatex file.tex''...
3
by: nugroho | last post by:
Ok---I was wondering...Is there any way to make C++ execute a UNIX command using Qt Designer? Like, I generate crypt command in my code. void frmUtama::cryp() { QString p =...
3
by: JB | last post by:
I'm writing a small utility and I need to be able to connect to a unix server and execute a couple of commands. How would I go about doing this? It's fairly simple from the command prompt using...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.