Question about stdlib.h system()

S

sdDirtySox

Hi all,

I'm using system to invoke a script remotely on another machine.

Something like this: system("/putty/plink.exe" 10.0.0.25 /home/foo);

The problem is, sometimes the foo script freezes the remote machine's
OS and system does not give control back to my program (which in turn
causes my program to hang.) I didn't write the foo script, so I'm not
sure why it's causing the remote machine's OS to freeze. I'd like to
have my program continue to execute even if the remote OS freezes.

So my question is: is there something I can do so that system isn't a
blocking call? Are there alternatives to system? Like I said, I just
need to invoke the script on the other machine.

Thanks in advance,
DS
 
B

Barry

Hi all,

I'm using system to invoke a script remotely on another machine.

Something like this: system("/putty/plink.exe" 10.0.0.25 /home/foo);

the signature of 'system' is
int system ( const char * command );

so write
system("/putty/plink.exe 10.0.0.25 /home/foo");

more over, no such way of passing arguments to a function call in C or C++.

I still don't know why your compiler accept your code like that
 
B

Barry

So my question is: is there something I can do so that system isn't a
blocking call? Are there alternatives to system? Like I said, I just
need to invoke the script on the other machine.

non-blocking way, then you have to run the script in another process.
I know nothing about Linux. But it seems that we can add '&' after the
line to run the command in another process so:

system("/putty/plink.exe 10.0.0.25 /home/foo &");
 
?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

Hi all,

I'm using system to invoke a script remotely on another machine.

Something like this: system("/putty/plink.exe" 10.0.0.25 /home/foo);

The problem is, sometimes the foo script freezes the remote machine's
OS and system does not give control back to my program (which in turn
causes my program to hang.) I didn't write the foo script, so I'm not
sure why it's causing the remote machine's OS to freeze. I'd like to
have my program continue to execute even if the remote OS freezes.

So my question is: is there something I can do so that system isn't a
blocking call? Are there alternatives to system? Like I said, I just
need to invoke the script on the other machine.

The question is off topic in this group, since there's no way to do that
platform independently. Try comp.os.ms-windows.programmer.win32 or one
of the microsoft.public.win32.programmer.win32 groups.

What you want to do is to spawn a new process or thread and run the
command from there.
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top