Using Command exec('bash -c "exec nohup setsid php -f

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
1clickarticle
Forum Newbie
Posts: 6
Joined: Mon Jun 04, 2007 2:49 am
Location: Cambodia

Using Command exec('bash -c "exec nohup setsid php -f

Post by 1clickarticle »

I got the problem here, I use exec function to run the external file.

Code: Select all

exec('bash -c "exec nohup setsid php -f test.php var=7777 > /dev/null 2>&1 &"');
It work, but it can not get the variable var.

First time this code is work properly, but when I change the web hosting, it got this problem.

How do I fix this problem.

Please help me :?: :?: :?:
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

How are you trying to access this "var" in test.php? (Post the file.)
1clickarticle
Forum Newbie
Posts: 6
Joined: Mon Jun 04, 2007 2:49 am
Location: Cambodia

Post by 1clickarticle »

Yes I want to get the var value in test.php. But I can not get since. I think this function is work before I upgrade my hosting plan.

I don't know how to config it.

Please help

feyd wrote:How are you trying to access this "var" in test.php? (Post the file.)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I don't think that answered by question....
1clickarticle
Forum Newbie
Posts: 6
Joined: Mon Jun 04, 2007 2:49 am
Location: Cambodia

Post by 1clickarticle »

I have two file

11.php and 12.php.

11.php

Code: Select all

<?php

$tt=$_REQUEST['var'];
	$fname="tt.txt";
		$file=@fopen($fname,'w');
		@fwrite($file, "Hell World...".$tt); 
		@fclose($file);
?>
12.php

Code: Select all

<?php

exec('bash -c "exec nohup setsid php -f 11.php var=7777 > /dev/null 2>&1 &"');

?>

I run 12.php in the browser, then 11.php run in background (I DO NOT run 11.php in browser), then 12.php will produce tt.txt.
in tt.txt file i want to add the var that i get from 12.php.

Result tt.txt file create, but the variable var in 12.php do not have in tt.txt.

that my problem.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If memory serves, the data will not be in $_REQUEST. It will be in $_SERVER.
1clickarticle
Forum Newbie
Posts: 6
Joined: Mon Jun 04, 2007 2:49 am
Location: Cambodia

Post by 1clickarticle »

Thank you Sir

My problem have been solved throught your answer.

Thank you BIG BIG.

:) :) :)
Post Reply