Help.. on output redirection
Hi there,
I have been browsing since morning to get the correct command to do this but never able to get the correct command i want. I have an application that write some important log in application screen this application is invoked through a shell script. now i want to redirect screen output to another file by making files for each hour.. eg- all the output of 1 PM to 2 PM should be stored in 2010_09_06_13.txt and all the output of 2 PM to 3 PM should be stored in 2010_09_06_14.txt. any help in this regard will be appreciated... thanks... |
Hi, welcome to LQ!
I don't think you can "change" the file standard output is redirected to on the fly; your only option will be to dice the file after the fact using tools like sed, awk or perl. Cheers, Tink |
Quote:
|
Hi,
Thanks for the reply. I think i could not explain the problem properly in my previous post, Kindly go through the below lines. 1) I have an application (basically its related to call handling of interactive voice response[IVR]). 2) I invoke the applilcation as- ./<application name> 3) This application writes all the application log in screen buffer which i can see in the application. 4) Now i want to run the application in background and want to write this screen log in a textfile, every hour a text file should be generated which i can monitor through <tail> command. 5) I can not close the application at any point of time to redirect the log in another file because if i close the application all the live trafic on the application gets disconnected. please help.. Thanks... |
Quote:
have an hourly file for re-direction. You can (via sed, awk, perl) generate chunks out of the one file which your app constantly writes to. Cheers, Tink |
Hi Tink,
It would be very helful for me if you can just give some examle to capture it through perl. assume my application name is davinci.sh i call the application as- sh davinci.sh Thanks.. |
Hi,
do you mean something like this Code:
#!/bin/bash You should follow Tinks suggestion. If your application is not a binary but a script, as the name suggests, then you could rewrite it and do the redirection in your script itself. |
While theoretically possible I've never done this. Maybe studying bits of the "tee", "tmux" and "screen" tools could help you to roll your own, they all do that with stdout each time you attack or reattach a session. All you need is to find a way to change the stdout file descriptor on-the-fly (gdb should be able to do that as well).
But as someone suggested, and since the program is really a script, and provided that you want to find a scripted solution: why not do it the right way and fix your script instead of wrapping it around a new one? The user above already pointed you in that direction and that's what -in my humble opinion- you should be doing. |
All times are GMT -5. The time now is 01:55 PM. |