Jump to content

Passing a full Loop to a UNIX Term through PHP


psykykkat

Recommended Posts

Hello Everyone! 

 

I feel like I'm going out of my mind.  I've been through the help files here, googled my heart out on every possible word convention I could think of and so I'm left asking for help from the public.

 

I'm running PHP 5 on a Windows Server.  My problem is as follows.  I am using PHP to telnet into and run commands on a UNIX system to look for files and parse logs. However, the latest roadblock is the need to pass a complete "for n in" loop including a UNIX designated variable like "$n".  Since PHP variables are also denoted by the "$" the script merely passes blank information, killing the loop.  All PHP variables are passing correct information, I just need the "$n" to appear on the UNIX system and not Well, I don't consider myself an expert in any sense of the word, but I can't seem to find an answer to this anywhere. 

 

Any help would be appriciated!

 

Thanks!

 

Kat

 

p.s. Knowing my luck it's a simple answer and I'm looking over it.

Link to comment
Share on other sites

enclose the statement you are passing to the unix system in single quotes.  Statements in single quotes are taken literally by php.  Php will substitute values for variables when they are inside statements wrapped in double quotes.

 

$x = "some text";

echo "x = $x";  //prints x = some text
echo 'x = $x";  //prints x = $x

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.