Jump to content

[SOLVED] Help please my command wont work


balistic

Recommended Posts

hi i was hoping someone here could help me, i am running a php script on my server and in the script i want to run this

$cmd = 'for name in `ls|grep ?`; do mv $name $name.torrent; done';
system($command2);

the $name variable isnt a php one which is i think whats stopping my string from working, it works using SSH on the server and system() works for everything else i try to run that doesnt have the $name var needed for this shell command. is there a way to make sure its outputting it the exact way it is to make it work?

 

thanks in advance

Link to comment
Share on other sites

Firstly... I don't think the ? is a valid regex to use with grep. I don't see why you even need grep here, what particular expression are you trying to match?

 

Secondly... according to your example you are trying to run $command2 via system() not $cmd as you defined it.

 

If you want to move all files, use.....

 

$cmd = 'for name in $(ls --color=none); do mv ${name} ${name}.torrent; done';

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.