balistic Posted July 29, 2007 Share Posted July 29, 2007 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 More sharing options...
trq Posted July 29, 2007 Share Posted July 29, 2007 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 https://forums.phpfreaks.com/topic/62303-solved-help-please-my-command-wont-work/#findComment-310044 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.