![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| script running with "ksh" dumping core but not with "sh" | simhe02 | HP-UX | 9 | 11-04-2008 08:52 PM |
| #!/bin/sh script fails at StringA | tr "[x]" "[y]" | by_tg | UNIX for Dummies Questions & Answers | 3 | 02-22-2008 12:17 PM |
| Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" | Lokesha | UNIX for Dummies Questions & Answers | 4 | 12-20-2007 01:52 AM |
| Q: Recording shell script screen output using "script" command ? | lalfonso.gomez | Shell Programming and Scripting | 4 | 01-18-2007 09:31 PM |
| Help! "Put" command from telnet session | tigote | UNIX for Dummies Questions & Answers | 5 | 12-27-2001 04:39 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
|||||
|
Since the script command would need to put info back to the screen, it may be a problem trying to force it into a file.
If you are looking to put the output of a command(s) into a file, just redirect for each command. ls -ltr >> tempfile.log pwd >> tempfile.log Or you could invoke the script to dump output into the tempfile.log... $ ./yourscript > ./tempfile.log |
|
|||||
|
Normally, when you use script it shows not just the output, but the commands that were run to get the output. Here's another alternative that won't require you to recode in order to print every command and its output.
Add the following to the top and bottom of your script: Code:
set -x ... set +x Code:
#!/bin/sh # test.sh set -x echo hello ls -ld /etc/hosts echo goodbye set +x Code:
$ ./test.sh 2>&1 | tee test.log + echo hello hello + ls -ld /etc/hosts lrwxrwxrwx 1 root root 12 Apr 17 2002 /etc/hosts -> ./inet/hosts + echo goodbye goodbye $ $ cat test.log + echo hello hello + ls -ld /etc/hosts lrwxrwxrwx 1 root root 12 Apr 17 2002 /etc/hosts -> ./inet/hosts + echo goodbye goodbye $ Keith |
|
|||||
|
Hi RTM, KDUFFIN!!
Thanks for ur suggestions. It was indeed a great help.. what kduffin said was something new... RTM, what u suggest was great, but the code then becomes full of redirections... The right code that helped me looks something like this: sh <<EOF>>./output.log ls -ltr ... EOF This was as per the suggestions from our moderator. Thanks ![]() |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|