Struck with System command

P

pavi

Hi,
I am using system command to execute a shell script in a C
program.
Usage system("sh file").
There are situations where the file may be empty. But
execution gets hung if the
file is empty. What might be the problem.

Regards,
Praveen Kumar A.S
 
B

Bart van Ingen Schenau

pavi said:
Hi,
I am using system command to execute a shell script in a C
program.
Usage system("sh file").
There are situations where the file may be empty. But
execution gets hung if the
file is empty. What might be the problem.

Regards,
Praveen Kumar A.S

Unfortunately, we can't tell whats wrong.
The interpretation of the argument to the system() function is very
system-dependent.
It is the intention that the string is passed to the command-interpreter
of the OS, as if the string were typed that way on the command prompt.
To figure out what is happening, you could try to manually give the
command you try to execute with system() and see what happens.

<OT>
It is possible that the sh shell keeps waiting for interactive input.
</OT>

Bart v Ingen Schenau
 
J

Joe Wright

pavi said:
Hi,
I am using system command to execute a shell script in a C
program.
Usage system("sh file").
There are situations where the file may be empty. But
execution gets hung if the
file is empty. What might be the problem.

Regards,
Praveen Kumar A.S
Really hard to say. You do know that file is the name of a command on
Unix and Linux systems. Not sure what it does if run with no arguments.
 
G

Guru Jois

Hi,
I am using system command to execute a shell script in a C
program.
Usage system("sh file").
There are situations where the file may be empty. But
execution gets hung if the
file is empty. What might be the problem.

Regards,
Praveen Kumar A.S

Are you sure that the command interpreter in you system is 'sh'?
If it is, it is unlikely the command hungs unless the script is made
so.
 

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

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top