Results 1 to 10 of 10
Hi,
I am launching a process which redirects output to a file:
Code:
wget SOMEURL -O DOWNFILE >LOGFILE 2>&1
I have several processes like this running, and I want to ...
- 09-24-2009 #1Just Joined!
- Join Date
- Sep 2009
- Location
- Bucharest, Romania
- Posts
- 5
[SOLVED] how to see process redirects
Hi,
I am launching a process which redirects output to a file:
I have several processes like this running, and I want to find the LOGFILE corresponding to a certain DOWNFILE. I useCode:wget SOMEURL -O DOWNFILE >LOGFILE 2>&1
to find the process, but the command column doesn't show the output redirects.Code:ps aux | grep -r 'wget.*DOWNFILE'
Is there any way to see the output redirects for a given process?
- 09-25-2009 #2Just Joined!
- Join Date
- Mar 2008
- Location
- Chennai, India
- Posts
- 26
Can't understand your question.
Do you mean that how does pipe operator redirect the streams?
- 09-25-2009 #3Just Joined!
- Join Date
- Sep 2009
- Location
- Bucharest, Romania
- Posts
- 5
- 09-25-2009 #4Just Joined!
- Join Date
- Mar 2008
- Location
- Chennai, India
- Posts
- 26
ps prints the command which starts the process you are interested in. It does not keep track of its input or output streams. If you want to see the name of file, you can see it by strace.
With strace you can also see the system calls executed while running you executable with the values passed to them and their return values. This can be handy but equally confusing also. Take care while using it and enjoy debugging!
Hope this was helpful.
Cheers,
Sarma
- 09-25-2009 #5Just Joined!
- Join Date
- Sep 2009
- Location
- Bucharest, Romania
- Posts
- 5
I tried strace, but it only showed the write calls, it didn't show what stream the process was writing to.
- 09-25-2009 #6Just Joined!
- Join Date
- Mar 2008
- Location
- Chennai, India
- Posts
- 26
Can you post your program and the strace snapshot?
- 09-25-2009 #7Just Joined!
- Join Date
- Sep 2009
- Location
- Bucharest, Romania
- Posts
- 5
Here's a sample process:
After that, from another script, I get the pid using ps and launch:Code:wget URL >test.log 2>&1
Sample strace output for this:Code:strace -p 15081
No mention of "test.log" in the output.Code:Process 15081 attached - interrupt to quit select(5, [4], NULL, NULL, {899, 261722}) = 1 (in [4], left {897, 981109}) read(4, "vAoj\217X\33\246\365\21\0\0$\240A\232\211\25\223\177\311\303\204\237\263H\360(\263\365\245\244\343"..., 16384) = 1340 write(3, "vAoj\217X\33\246\365\21\0\0$\240A\232\211\25\223\177\311\303\204\237\263H\360(\263\365\245\244\343"..., 1340) = 1340 write(2, " "..., 1) = 1 write(2, "."..., 1) = 1 select(5, [4], NULL, NULL, {900, 0}) = 1 (in [4], left {899, 998986}) read(4, "\341\233\360a5\320\210v\352\230\244M\205{\244\201\241e\202\243A\363\301\4=\242Z>V\373\266\335C"..., 16384) = 1340 write(3, "\341\233\360a5\320\210v\352\230\244M\205{\244\201\241e\202\243A\363\301\4=\242Z>V\373\266\335C"..., 1340) = 1340 write(2, "."..., 1) = 1 select(5, [4], NULL, NULL, {900, 0}) = 1 (in [4], left {899, 998486}) read(4, "\347\356\317\352\235<W\201'\267=\317\224`\313\272e#\315J.\1G\274\271\247mU\365\2263\377\244"..., 16384) = 1340 write(3, "\347\356\317\352\235<W\201'\267=\317\224`\313\272e#\315J.\1G\274\271\247mU\365\2263\377\244"..., 1340) = 1340 write(2, "."..., 1) = 1 write(2, "."..., 1) = 1 select(5, [4], NULL, NULL, {900, 0}) = 1 (in [4], left {899, 964464}) read(4, "6\263\32\270\221\344$\367\320\177\351h\260B-Z\222\261\243\237&kp\346\276F\10m\373\326\270w\334"..., 16384) = 1340 write(3, "6\263\32\270\221\344$\367\320\177\351h\260B-Z\222\261\243\237&kp\346\276F\10m\373\326\270w\334"..., 1340) = 1340 write(2, "."..., 1) = 1 select(5, [4], NULL, NULL, {900, 0}) = 1 (in [4], left {899, 998809}) read(4, "\203\32T'\304\3340\222\250h\355\2774\247\325\216\353c\366;$_\300\24s\2052\352\311H\30,\372"..., 16384) = 1340 write(3, "\203\32T'\304\3340\222\250h\355\2774\247\325\216\353c\366;$_\300\24s\2052\352\311H\30,\372"..., 1340) = 1340 write(2, "."..., 1) = 1 select(5, [4], NULL, NULL, {900, 0}) = 1 (in [4], left {899, 998745}) read(4, "w\17\6J\21\231\374\316\n|\200'\356\253:x:\254?!\376\276\220\317\324\323;[GQ^\25d"..., 16384) = 1340 write(3, "w\17\6J\21\231\374\316\n|\200'\356\253:x:\254?!\376\276\220\317\324\323;[GQ^\25d"..., 1340) = 1340 write(2, "."..., 1) = 1 write(2, "."..., 1) = 1 select(5, [4], NULL, NULL, {900, 0}) = 1 (in [4], left {899, 998752}) read(4, "O\203r\311\272\371\33\246\277\3171\302\37\"b\331\224\254\271\243\322$\243\220\335M.\301_\356\7)\275"..., 16384) = 1340 write(3, "O\203r\311\272\371\33\246\277\3171\302\37\"b\331\224\254\271\243\322$\243\220\335M.\301_\356\7)\275"..., 1340) = 1340 write(2, "."..., 1) = 1 select(5, [4], NULL, NULL, {900, 0}) = 1 (in [4], left {899, 998494}) Process 15081 detached
The thing I'm interested in:
- script A launches wget URL >LOGFILE
- script B knows URL and wants to determine LOGFILE
- 09-25-2009 #8Linux Newbie
- Join Date
- Mar 2009
- Posts
- 228
You could use lsof
Code:lsof -p 15081
- 09-25-2009 #9Just Joined!
- Join Date
- Sep 2009
- Location
- Bucharest, Romania
- Posts
- 5
- 09-26-2009 #10Just Joined!
- Join Date
- Sep 2009
- Posts
- 4
I think if you use ptrace,then you can see the pipe function call.



