Solved

system() call hangs

Posted on 2003-11-15
11
265 Views
Last Modified: 2009-07-29
In a PHP program(php1.php) i have a system() call like this:

system('/usr/local/bin/sh php2.php arg1');

The original PHP program (php1.php) when executed hangs. It stops responding. But if the system call is commented the program works fine.

The second PHP file (php2.php) when executed from the command line works fine. But when the same php2.php is called from the php1.php using the system() the code stops responding.

What might be the reason?

Thanks,
Navanee
0
Comment
Question by:rnavanee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 14

Expert Comment

by:ThG
ID: 9753800

What you are doing is basically wrong.
What is '/usr/local/bin/sh'? a bash compiled yourself?
Do this command work if typed in the command line?
 $ /usr/local/bin/sh php2.php arg1

Even if it works, what you typed above means:
/bin/sh -c '/usr/local/bin/sh php2.php arg1'
which makes no sense.

What you probably want is this:
system("/usr/local/bin/php -f php2.php arg1");

Let me know if my considerations are correct :-)
0
 

Author Comment

by:rnavanee
ID: 9753858
Sorry I made a mistake ...

The call is ..
system('/usr/local/bin/php php2.php arg1');

This call makes causes the execution to hang.

I tried using 'php -f';  Even this fails...


Thanks,
Navanee


0
 
LVL 14

Expert Comment

by:ThG
ID: 9753966
and what happens from the command line?
 $ php -f php2.php arg1

note that without the -f it's normal that it hangs, because it tries to read from standard input something that will never arrive
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 6

Expert Comment

by:aolXFT
ID: 9759945
system('/usr/local/bin/php php2.php arg1');

hmmm

Do you have shell access to the machine that this is running on? If so, then try executing the command on the command line.

Does it hang?

Try

system('/usr/local/bin/php php2.php arg1 &');

If this does work it will be a temperary fix. you'll need to fix the command so that it doesn't hang.

You might also make sure that /usr/local/bin/php is the correct path.

Why are you trying to do this? There's usually a better way to do things than using system(). You also lose the advantages of running the system as a module(if you are doing so).
0
 

Author Comment

by:rnavanee
ID: 9762701
The call was

...
system ('/usr/local/bin/php $scriptName $arg');
...

The Single quote (') is the cause for all the problems...

I found it by myself.

Thanks
0
 
LVL 14

Expert Comment

by:ThG
ID: 9762896
Sure it was, but another time please ask the question as it is in reality.
0
 

Author Comment

by:rnavanee
ID: 9762946
Yes. I agree. It was my mistake. Sorry for that.
0
 
LVL 9

Expert Comment

by:techtonik
ID: 12198529
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12573094
PAQed with points refunded (50)

modulo
Community Support Moderator
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question