Skip to main content
Question

best logging method for scripts


Forum|alt.badge.img+31
  • Honored Contributor
  • 2721 replies

I have been scrapping my scripts and combining them all into 1 post image script for configurations that are just needed. What I cannot do in MCX I do via shell scripts. However, combining them all racks up like 500 lines of code sometimes. I would like the output of all commands to log to a log file, and remain there unless the script finishes. The last line in the script wipes out the log files. I have looked at the logger command, tee, script, using stdout, and so forth.

Not really sure the best way to go. Also, anyone know how to say have it populate the imaging logs in the JSS? That would be nice too, as sometimes I remotely image machines.

Thanks

Tom

4 replies

  • 0 replies
  • August 12, 2010

I have been scrapping my scripts and combining them all into 1 post image
script for configurations that are just needed. What I cannot do in MCX I
do via shell scripts. However, combining them all racks up like 500 lines
of code sometimes. I would like the output of all commands to log to a
log file, and remain there unless the script finishes. The last line in the
script wipes out the log files. I have looked at the logger command, tee,
script, using stdout, and so forth. Not really sure the best way to go. Also, anyone know how to say have it
populate the imaging logs in the JSS? That would be nice too, as sometimes
I remotely image machines.

I like this method for having a script log.

set -xv; exec 1>/Location/to/save/log.txt 2>&1

This shows the line that's executed and then under that shows any messages
coming back from the command. Cant help you with populating the JSS logs
though. HTH

- JD


stevewood
Forum|alt.badge.img+35
  • Employee
  • 1797 replies
  • August 13, 2010

Okay, I can plug through scripts fairly well, but I'm a little unsure on
this. Where exactly in a shell script would you put this line? Would it go
at the top of the script?

Steve Wood
Director of IT
swood at integer.com

The Integer Group | 1999 Bryan St. | Ste. 1700 | Dallas, TX 75201
T 214.758.6813 | F 214.758.6901 | C 940.312.2475


Forum|alt.badge.img+5
  • Contributor
  • 75 replies
  • August 13, 2010

I put it where I would have my very first command, I believe that is starts
logging from the point that it is ran, very handy.

--
Alan Benedict
?
Macintosh Technician
The Integer Group
http://www.integer.com


  • 0 replies
  • August 16, 2010

Yes, I put this right after my shebang line so it will log every command
from that point down.

- JD


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings