Re: Program Execution and reading results

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks guys for your response. I think this output from reply can solve my
problem. Becuase I can return some value like ' fileready == true' as the
output from the executable program. And when fileready is true I can read
the output text file. Can you please explain a little bit what kind of
output shell_exec will retrieve. I mean how can i define a boolean variable
like fileready and have it returned to php as output so that I know that
text file is ready to be read.

Thanks


Daniel Brown-5 wrote:
> 
> On 6/21/07, Zoltán Németh <znemeth@xxxxxxxxxxxxxx> wrote:
>> 2007. 06. 21, csütörtök keltezéssel 10.46-kor Richard Heyes ezt írta:
>> > > hmm I thought the OP's question was about how can he get
>> output/return
>> > > value from the external program (the file name for example) - maybe
>> it
>> > > was my misunderstanding
>> >
>> > In which case I would still use shell_exec():
>> >
>> > <?php
>> >       $output = shell_exec('ls -l');
>> > ?>
>> >
>>
>> okay I admit my ignorance :)
>> I didn't know about the return value of shell_exec, now I checked the
>> manual and wow there it is...
>> so both can be used to get output
>>
>> greets
>> Zoltán Németh
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
> 
> <?
>     $filetoexecute = "somefile.sh";
>     $filetocreate = "newfile.txt";
>     $filetoappend = "existingfile.txt";
> 
>     // To create a file, redirect the output with a single right carat:
>     exec($filetoexecute.' > '.$filetocreate.' 2>&1',$ret);
>     // To append to a file, redirect output with double right carats:
>     // exec($filetoexecute.' >> '.$filetoappend.' 2>&1',$ret);
> 
>     file_exists($filetocreate) ? $file_written = True : $file_written =
> False;
> 
>     // Because we used 2>&1, errors are redirected to stdout
>     // $ret contains the redirected error output from the command line
> ?>
> 
> -- 
> Daniel P. Brown
> [office] (570-) 587-7080 Ext. 272
> [mobile] (570-) 766-8107
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Program-Execution-and-reading-results-tf3956489.html#a11235284
Sent from the PHP - General mailing list archive at Nabble.com.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux