Branden Wagner Posted August 6, 2006 Share Posted August 6, 2006 $pass = system("mail/crypt $password");works and does the crypt right however it also prints it on the screen and i dont want it to output the crypt on to the screen what am i doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/16684-system-command/ Share on other sites More sharing options...
ronverdonk Posted August 6, 2006 Share Posted August 6, 2006 You can redirect the ouput to a file or another voutput stream (such as a null device).[code]$pass = system("mail/crypt $password >file.txt");[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16684-system-command/#findComment-70110 Share on other sites More sharing options...
Branden Wagner Posted August 7, 2006 Author Share Posted August 7, 2006 i just want the output stored in the $pass variable. because the next step in the script it to put it in the db. Quote Link to comment https://forums.phpfreaks.com/topic/16684-system-command/#findComment-70623 Share on other sites More sharing options...
Daniel0 Posted August 7, 2006 Share Posted August 7, 2006 [code]$pass = exec("mail/crypt $password");[/code]Try that, I believe that [url=http://php.net/exec]exec[/url] do not output the result. Quote Link to comment https://forums.phpfreaks.com/topic/16684-system-command/#findComment-70663 Share on other sites More sharing options...
ronverdonk Posted August 7, 2006 Share Posted August 7, 2006 You can use the trick from the PHP manual comments. This one works, capturing all exec output in an array that you can walk.[code]<?php$result = array();exec( "dir", &$result);foreach ( $result as $v ){ echo "HEREITIS: $v <br />";}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16684-system-command/#findComment-70689 Share on other sites More sharing options...
Branden Wagner Posted August 7, 2006 Author Share Posted August 7, 2006 exec worked thanks.... so... whats the difference between system and exec?? Quote Link to comment https://forums.phpfreaks.com/topic/16684-system-command/#findComment-70826 Share on other sites More sharing options...
ronverdonk Posted August 8, 2006 Share Posted August 8, 2006 I really don't know the nitty gritty of the differences between these 2 commands, but I always use exec because it returns my output nicely in an array. The following shows the definitions from tht PHP documentation:[code]string system ( string command [, int return_var])system() is just like the C version of the function in that it executes the given command and outputs the result. If a variable is provided as the second argument, then the return status code of the executed command will be written to this variable. [/code][code]string exec ( string command [, array output [, int return_var]])exec() executes the given command, however it does not output anything. It simply returns the last line from the result of the command. If you need to execute a command and have all the data from the command passed directly back without any interference, use the passthru() function. If the output argument is present, then the specified array will be filled with every line of output from the command. [/code] Quote Link to comment https://forums.phpfreaks.com/topic/16684-system-command/#findComment-71120 Share on other sites More sharing options...
Daniel0 Posted August 8, 2006 Share Posted August 8, 2006 [quote author=ronverdonk link=topic=103143.msg411716#msg411716 date=1155043827]I really don't know the nitty gritty of the differences between these 2 commands[/quote]If you read the quotes you posted, then you would know that system outputs the result and exec returns the last line of the result. Quote Link to comment https://forums.phpfreaks.com/topic/16684-system-command/#findComment-71132 Share on other sites More sharing options...
ronverdonk Posted August 8, 2006 Share Posted August 8, 2006 Are you earning brownie points for this post? I was talking about the internals (nitty gritty) of both commands, not about the externals such as returning output or not. Quote Link to comment https://forums.phpfreaks.com/topic/16684-system-command/#findComment-71153 Share on other sites More sharing options...
Daniel0 Posted August 8, 2006 Share Posted August 8, 2006 Well, there is no difference in how the command is executed, the only difference is the output/returning. Quote Link to comment https://forums.phpfreaks.com/topic/16684-system-command/#findComment-71259 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.