how to capture script execution in log file?

Asked by Sathyamoorthy on 2013-07-19

Hi,

I am writing python script to test my Backup&Recovery application. I want script exeution should be captured some file.

So how to capture the execution logs in a file. Please some one help to do that,

Thanks,
V.Sathyamoorthy

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu python2.7 Edit question
Assignee:
No assignee Edit question
Last query:
2013-07-19
Last reply:
2013-07-19
N1ck 7h0m4d4k15 (nicktux) said : #1

Example 1

    sudo apt-get update 1> apt-get.log

will capture the results of sudo apt-get update into apt-get.log

Example 2

Capture both stdout and stderr to a file (below command is wrong and will produce an error. But no matters if the execution (or command) is wrong or correct, the results will be captured inside apt-get-error.log)

sudo apt-get updATE > apt-get-error.log 2>&1

Regards
 NikTh

Hi,
Thanks for the information.

My script is generic to windows and unix platforms. could you please give me the global solution for the same.

Thanks in Advance ,
V.Sathyamoorthy

N1ck 7h0m4d4k15 (nicktux) said : #3

For Windows.. hmm sorry, I don't know. Better would be to ask on a Windows help desk (forum .. etc)

For Linux, you can execute the script from a terminal and follow the examples above to capture the output.

Regards
 NikTh

Can you help with this problem?

Provide an answer of your own, or ask Sathyamoorthy for more information if necessary.

To post a message you must log in.