map200uk Posted May 4, 2007 Share Posted May 4, 2007 hi, bit confused at present, if i do $output = shell_exec('ln'); echo "<pre>$output</pre>"; i get no result but yet for df-h / uptime/whoami/ ls -art etc a result is shown ive checked the user 'nobody' and it has permission to run the ln command? so surely i should get some kind of response Quote Link to comment Share on other sites More sharing options...
DaveEverFade Posted May 4, 2007 Share Posted May 4, 2007 I don't know much about shell_exec but you might wanna try my favourite bit of code (before the command) to help diaganose the problem error_reporting(E_ALL); ini_set('display_errors', '1'); Quote Link to comment Share on other sites More sharing options...
map200uk Posted May 4, 2007 Author Share Posted May 4, 2007 tried it-got nothing bit confused as to why most commands work but for ln i get nothing, not even the root@clark xmltest]# ln ln: missing file argument Try `ln --help' for more information. Quote Link to comment Share on other sites More sharing options...
map200uk Posted May 4, 2007 Author Share Posted May 4, 2007 anyone have any ideas?:| Quote Link to comment Share on other sites More sharing options...
map200uk Posted May 4, 2007 Author Share Posted May 4, 2007 bump any ideas? didnt wanna repost-but im still no wiser as to what could be causing this Quote Link to comment Share on other sites More sharing options...
neel_basu Posted May 4, 2007 Share Posted May 4, 2007 Cause you havn't given any arguments with that command but that needs arguments See thsi page http://linux.about.com/od/commands/l/blcmdl1_ln.htm for help on this command Quote Link to comment Share on other sites More sharing options...
utexas_pjm Posted May 4, 2007 Share Posted May 4, 2007 As the previous poster suggested ln cannot be run without arguments. If you type ln into the console you'll get ln: missing file argument Try `ln --help' for more information. However this is sent to std error not std out. I believe exec only returns output piped through std out. Best, Patrick Quote Link to comment Share on other sites More sharing options...
map200uk Posted May 4, 2007 Author Share Posted May 4, 2007 ahhh ok i get it, i thought id get the error message too thanks mate Quote Link to comment Share on other sites More sharing options...
map200uk Posted May 4, 2007 Author Share Posted May 4, 2007 see thing is it works- you were correct thank you! is there no way to check the command has been executed like with say whoami i could do if(exec('whoami') { echo "bla" } else { echo "blaa"; } thankls guys Quote Link to comment Share on other sites More sharing options...
effigy Posted May 4, 2007 Share Posted May 4, 2007 I recommend always: 1. Redirecting STDERR to STDOUT (2>&1). 2. Checking the return value of the command. Quote Link to comment Share on other sites More sharing options...
map200uk Posted May 4, 2007 Author Share Posted May 4, 2007 surely tho if the command executes perfectly there is no return? nothing passed to stdout? Quote Link to comment Share on other sites More sharing options...
effigy Posted May 4, 2007 Share Posted May 4, 2007 A command always has a return value. Success is typically 0, with errors and warnings being non-zero. Quote Link to comment Share on other sites More sharing options...
map200uk Posted May 4, 2007 Author Share Posted May 4, 2007 ahh right ok a boolean value yea, no output tho i meant could someone help with a problem with exec-when i use exec to create sym links the script NEVER finished function findMusic($dir) { $musicList = array(); $dirHandle = opendir($dir); $dir2 = "/opt/lampp/htdocs//mp3"; // echo "<br> DIRECTOR IS \n $dir"; while (($file = readdir($dirHandle)) !== FALSE) { if ($file == "." || $file == "..") continue; if (is_dir($dir . "/" . $file)) $musicList = array_merge($musicList, findMusic($dir . "/" . $file)); else { $extension = end(explode(chr(46), $file)); // print $extension; if (strtolower($extension) == "mp3") { $musicList[] = $dir . "/" . $file; } echo "<br>mp3 found in \n $dir"; echo "<br>commnd is \n $command"; echo "attempting to create some sym links"; // shell_exec("ln -s $dir $dir2"); } } closedir($dirHandle); return $musicList; } Quote Link to comment Share on other sites More sharing options...
trq Posted May 4, 2007 Share Posted May 4, 2007 You would be best off using php's symlink function. Quote Link to comment Share on other sites More sharing options...
map200uk Posted May 4, 2007 Author Share Posted May 4, 2007 i did look at that, so it would work same way? if dir found pass the dir to symlink along with htdocs/mp3 and i now have a symlink in htdocs/mp3? thanks bud Quote Link to comment Share on other sites More sharing options...
trq Posted May 4, 2007 Share Posted May 4, 2007 Read the manual entry. You need to provide a name for the symlink, not just the directory you want it to appear in. symlink("filebeinglinkedto","nameoflink"); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.