Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Executing Program In Unix From VC++

Status
Not open for further replies.

raochetan

Programmer
Aug 20, 2001
62
IN
I want to connect to the Unix Server and exeute a command in that machine from my program. Which Win32 API should i use to achive this? Code Example will be nice.

regards
raochetan
 
Hi!

Well, I cant give you a code example, but a hint. At least I know, that there is no standard Windows api. You can use the REXEC Protocoll to execute a command on your UNIX Server. But the RExec command from Windows doesnt work with UNIX. So you have to find a class or Programm, that is able to work with your system.

Greetings
Remo
 
Perhaps you could make a simple socket program thats sits and waits on your unix box for a certain transmission and then executes a certain command. I would just advise that you dont make you program to open to suggestion lest someone take advantage of it.
 
The simplyest way:

On Windows side:

1. put the commands you want to be executed on Unix to the file, say, "my_batch.sh"
2. system("ftp -s:my_put_script.ftp my_unix_host_name");
where "my_put_script.ftp" looks like following:

my_ftp_account
my_ftp_password
put my_batch.sh
bye

On Unix side some background script must be running, something like this:

#!/bin/sh
while $TRUE; do
if test -a my_batch.sh; then
./my_batch.sh
rm my_batch.sh
fi
sleep 5
done

 
Hi!

I think this would be a good solution, if you dont need to get back any results from the UNIX Server. I would implement the call of the script with cron, instead of a running script.

Greetings
Remo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top