Writing to jamf log from scripts

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 07-03-2007 01:53 AM
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>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 07-03-2007 07:46 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 07-03-2007 08:09 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 07-03-2007 09:34 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 07-31-2007 09:08 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 07-31-2007 01:37 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 07-31-2007 04:32 PM
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?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 07-31-2007 07:04 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 08-01-2007 06:32 AM
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".

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 09-24-2007 08:14 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 09-24-2007 08:34 AM
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...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 09-24-2007 10:01 AM
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...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 11-14-2007 07:09 AM
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
