1

I am trying to pass a Text string as a variable using the PHP Exec command line, but the entire text is not being passed.

The text is like this:

$title_page = 'Channel | This is the channels title';

then the exec line is:

exec("$path_to_php $emailer $article_sub_security_var $article_id > /dev/null &");

Im retrieving them like this:

$article_sub_security_var = $_SERVER['argv'][1];
$article_id = $_SERVER['argv'][2];
$page_title = $_SERVER['argv'][3];

The command line is working properly with the exception of $page_title. It only returns part of the string and not all of it.

Any suggestions to pass it in full much appreciated.

1
  • 2
    I'm not seeing $title_page or even $page_title anywhere in your exec statement :-/ Commented Mar 24, 2013 at 16:03

1 Answer 1

1

The command line is working properly with the exception of $page_title. It only returns part of the string and not all of it.

I guess your problem is the | (pipe) in your page title, try using escapeshellcmd on $title_page before.

Sign up to request clarification or add additional context in comments.

4 Comments

Sorry. The command does include $page_title in it. My error. darthmaim - could you show me what the code would look like on $page_title. Would it go in the exec command line? so something like this: exec("$path_to_php $emailer $article_sub_security_var $article_id escapeshellcmd($page_title) > /dev/null &");
I just tried using escapeshellcmd($page_title) but it doesnt work. I tried removing the pipe, but it seems to only return the first word of the text string. It seems to return any text upto the occurance of the first space.
you have to include $page_title in quotes ("), since it contains spaces, like so: exec("$path_to_php $emailer $article_sub_security_var $article_id \"$page_title\" > /dev/null &");
Thank you. That works perfectly. I had also just tried escapeshellarg which also worked. Thankyou very much.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.