?
Solved

system() call hangs

Posted on 2003-11-15
11
Medium Priority
?
266 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

741 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