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
https://forums.phpfreaks.com/topic/62303-solved-help-please-my-command-wont-work/
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';

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.