Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Capture complicated script command output

Status
Not open for further replies.

thedaver

IS-IT--Management
Jul 12, 2001
2,741
0
0
US
I am trying to debug a complicated bash script.
Rather than run the script, I'd like to have its commands sent to a text file where I can view them. Any ideas on how this is done? I've messed with 2>&1 1>file.txt but that's redirecting the output of commands. I need to actually capture the commands that are run and save those.

EXAMPLE:
#!/bin/sh
ls
date
---end file----
I want to capture as output
"ls
date"

not the actualy 'ls' and 'date' output.

Thx.

Surfinbox.com Business Internet Services - National Dialup, DSL, T-1 and more.
 
Have you tried using the -v option to the shell. This apparently (though I've never used it) prints shell input lines as they are read. HTH.
 
RTFM results in adding
"set -x" as the first line in the file.
Now the commands themselves are printed as
+ ls
[ls command output]
+ date
[date command output]

thanks for helping!

Surfinbox.com Business Internet Services - National Dialup, DSL, T-1 and more.
 
try setting "bash +x" & "bash -x", this shoud be what ya need.

rgd's
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top