Skip to main content
Question

Writing to jamf log from scripts


Hi,

Does anybody know if there is an explicit way of writing to the JAMF log
from shell or Apple scripts?

Cheers
Dan
-- Daniel Farnworth
IT Manager
The Creative Partnership
daniel.farnworth at thecreativepartnership.co.uk

http://www.thecreativepartnership.co.uk
Tel: +44 (0)20 7439 7762
Fax: +44 (0)20 7437 1467

PGP Public Key available<BR>

12 replies

  • 0 replies
  • July 3, 2007

I can see that being difficult (not to mention probably undesirable), I was
thinking that something like the following would be really handy when trying
to troubleshoot scripts that run whilst imaging

$ jamf log --jsslog [error | comment as string]

Any ideas peeps, what do you all do?

Dan


nick11
Forum|alt.badge.img+19
  • Employee
  • 43 replies
  • July 3, 2007

Dan,

The results of any scripts that are run at imaging time are already logged centrally on the JSS after the machine completes the imaging process and can be found within the JSS web interface at Logs > Autorun Logs. Logs for scripts that are run through Casper Remote and Policies can also be found within the "Logs" tab.

I hope this is the information you are looking for!

Regards,

Nick Amundsen
Product Specialist
............................................................................
JAMF Software
1011 Washington Ave S. #350
Minneapolis, MN 55415
............................................................................
US Support (612) 216-1296
UK Support (020) 3002 3907

Minneapolis (612) 605-6625
............................................................................
http://www.jamfsoftware.com


  • 0 replies
  • July 3, 2007

Thanks Nick,

I figured that some stuff was being logged, but for troubleshooting
purposes, I need to be able to echo various messages out during the running
of the script to check things are happening correctly. Only my final exit
message seems to turn up in the log, is this correct behaviour?

Cheers
Dan


Forum|alt.badge.img+7
  • Contributor
  • 27 replies
  • July 31, 2007

All,
I know it has been a long time since this thread started, but here goes. It looks like the biggest problem is that stderr is a black hole. You have to catch every error and write it to stdout for shell/ perl scripts.
AppleScript is different animal. I recently started testing mine from the terminal using osascript. For the last round of tests and production, I stuff all possible errors in a variable and return that variable at the end. The problem is if something happens I don't predict, it won't be logged.

Please correct me if I'm wrong.

thanks,

Jack


  • 0 replies
  • July 31, 2007

Nice one for looking so deep into this Jack.

Based on what you're saying all that is really needed is a way of redirecting stderr to stdout for the duration of the script. I know this can be done on a line by line basis, but I've never seen a solution for a whole script.

Any ideas peeps?

Dan


Forum|alt.badge.img+7
  • Contributor
  • 27 replies
  • July 31, 2007

It should be different for each language. In perl STDIN STDOUT and STDERR are filehandles so you may be able to read/write/redirect as you would any other handle. Maybe since stderr and stdout are environment variables, you can set them at the beginning of the script and return them to defaults at the end of the script. Just guessing.

I'm trying to script a backup before imaging and the lack of feedback is killing me. Getting this worked out now will make life a lot easier down the road. I'll test tomorrow morning and let you know how it turns out.

Jack

BTW... what language are you using?


  • 0 replies
  • August 1, 2007

I'm just usig regular Bash scripts, but I'm cobbling together really as I'm not that experienced with Bash scripting.

I was having the same nightmare (and still am with some scripts) trying to troubleshoot why they weren't running correctly. I'm away from our regular environment at the oment so I can't test anything, but when I get back to London I'll have a crack at a few things.

Any perls (sic) of wisdom from any JAMF folks?

Dan
-- Daniel Farnworth IT Manager The Creative Partnership daniel.farnworth at thecreativepartnership.co.uk

http://www.thecreativepartnership.co.uk Tel: +44 (0)20 7439 7762 Fax: +44 (0)20 7437 1467

PGP Public Key available


Forum|alt.badge.img+7
  • Contributor
  • 27 replies
  • August 1, 2007

Normally in Bash you just put 'exec 2>&1' to redirect errors to stdout. When I put that the beginning of a script, it will write the syntax errors correctly, but other errors (for ex. ls /stuff when stuff doesn't exist) produce the error "The script does not exist in the Scripts folder".


  • 0 replies
  • September 24, 2007

Hi folks,

Just wanted to bump this and see if anyone had managed to find a solution or
if Jamf could help us out?

Once again I'm trying to test a script and I need to see what's going on,
but I'm flailing around in the dark...

Cheers
Dan


  • 0 replies
  • September 24, 2007

Er, scratch that, it now seems to be working okay for me...

If I run

$ echo "Here be output"

In a script, I get the output logged in the JSS at Logs/Autorun Log...


  • 0 replies
  • September 24, 2007

Thanks Dan, that's a really nice trick and one that will help a lot I think!

Wish I'd known about that a while ago...


  • 0 replies
  • November 14, 2007

Another trick for troubleshooting scripts. I send output to system log on the client with this:

syslog -s -l 3 "Now is the time all good men..."

Tom


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