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.
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.
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.
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
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.