LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   screen command issue with redirecting STDOUT (https://www.linuxquestions.org/questions/linux-software-2/screen-command-issue-with-redirecting-stdout-848102/)

G-Fox 12-03-2010 02:57 AM

screen command issue with redirecting STDOUT
 
Hello,

try to do:

screen -dmS test 'ls > result.txt'

no result.txt file created...

If I put command 'ls > result.txt' in shell script test.sh and run:

screen -dmS test ./test.sh

result.txt file was created and have list of files, but I need to work without shell script.

My main task is to run multiple perl scripts from php web site in bacground and display perl script output in web without hangup or waiting for script to finish.

If someone have better solution than screen it will be very wellcome.

Thanks.

i92guboj 12-03-2010 03:40 AM

Quote:

Originally Posted by G-Fox (Post 4179234)
Hello,

try to do:

screen -dmS test 'ls > result.txt'

no result.txt file created...

If I put command 'ls > result.txt' in shell script test.sh and run:

screen -dmS test ./test.sh

result.txt file was created and have list of files, but I need to work without shell script.

Try to use double quotes instead. I can't be sure it will work, it really depends on how screen does the parsing of the input. But it's worth a try.

Code:

screen -dmS test "ls > ~/result.txt"

Quote:

My main task is to run multiple perl scripts from php web site in bacground and display perl script output in web without hangup or waiting for script to finish.

If someone have better solution than screen it will be very wellcome.
I am not sure this is the right approach, never looked into it myself. But there must be some tty library that you can use instead, like vte. In any case, if you prefer a terminal multiplexer for some reason, you should look into tmux which should be lighter. That's one thing to try if no one can give a better advise.

G-Fox 12-03-2010 04:29 AM

Quote:

Originally Posted by i92guboj (Post 4179265)
Try to use double quotes instead. I can't be sure it will work, it really depends on how screen does the parsing of the input. But it's worth a try.

Code:

screen -dmS test "ls > ~/result.txt"

Same result... no file created.

Quote:

Originally Posted by i92guboj (Post 4179265)
I am not sure this is the right approach, never looked into it myself. But there must be some tty library that you can use instead, like vte. In any case, if you prefer a terminal multiplexer for some reason, you should look into tmux which should be lighter. That's one thing to try if no one can give a better advise.

Problem solved will use in command end '&'.
Code:

exec('script.pl &> log &');


All times are GMT -5. The time now is 06:54 PM.