[Casper] Writing to jamf log from scripts
Tom Francais
tjf at Princeton.EDU
Wed Nov 14 07:09:04 PST 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
On Sep 24, 2007, at 11:34 AM, Daniel Farnworth wrote:
> 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...
>
>
>
>
> On 24/09/2007 16:14, "Daniel Farnworth"
> <daniel.farnworth at thecreativepartnership.co.uk> wrote:
>
>> 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
>>
>>
>> On 01/08/2007 14:32, "Jack E. Bishop" <bishopja at ninds.nih.gov> wrote:
>>
>>> 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".
>>>
>>>
>>>
>>> On Jul 31, 2007, at 10:04 PM, Daniel Farnworth wrote:
>>>
>>>> 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
>>>>
>>>>
>>>> ----- Original Message -----
>>>> From: Jack E. Bishop
>>>> [mailto:bishopja at ninds.nih.gov]
>>>> To: Daniel Farnworth
>>>> [mailto:daniel.farnworth at thecreativepartnership.co.uk]
>>>> Cc: Nick Amundsen
>>>> [mailto:nick at jamfsoftware.com], Topics Related to the Casper Suite
>>>> [mailto:casper at list.jamfsoftware.com]
>>>> Sent: Wed, 01 Aug 2007 00:32:26
>>>> +0100
>>>> Subject: Re: [Casper] Writing to jamf log from scripts
>>>>
>>>>
>>>>> 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?
>>>>>
>>>>> On Jul 31, 2007, at 4:37 PM, Daniel Farnworth wrote:
>>>>>
>>>>>> 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
>>>>>>
>>>>>> On 31 Jul 2007, at 09:08, Jack E. Bishop wrote:
>>>>>>
>>>>>>> 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
>>>>>>>
>>>>>>> On Jul 3, 2007, at 12:34 PM, Daniel Farnworth wrote:
>>>>>>>
>>>>>>>> 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
>>>>>>>>
>>>>>>>>
>>>>>>>> On 03/07/2007 16:09, "Nick Amundsen" <nick at jamfsoftware.com>
>>>> wrote:
>>>>>>>>
>>>>>>>>> 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
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On 7/3/07 9:46 AM, "Daniel Farnworth"
>>>>>>>>> <daniel.farnworth at thecreativepartnership.co.uk> wrote:
>>>>>>>>>
>>>>>>>>> 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
>>>>>>>>>
>>>>>>>>> On 03/07/2007 15:30, "Tom Francais" <tjf at Princeton.EDU> wrote:
>>>>>>>>>
>>>>>>>>>> Dan, I understand now. I believe the JSS stores everything in
>>>>>>>> a MySQL
>>>>>>>>>> database. I don't know if it's possible to bypass the JSS and
>>>>>>>> inject
>>>>>>>>>> something directly into the database.
>>>>>>>>>>
>>>>>>>>>> Tom
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On 7/3/07 9:44 AM, "Daniel Farnworth" wrote:
>>>>>>>>>>
>>>>>>>>>>> Good call Tom, unfortunately as I should have specified
>>>> in my
>>>>>>>> original mail,
>>>>>>>>>>> I am booted off a read-only netboot disk at the point when
>>>>>>>> the scripts run.
>>>>>>>>>>> I need to write to the logs that you can see in the JSS...
>>>>>>>>>>>
>>>>>>>>>>> Cheers
>>>>>>>>>>> Dan
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On 03/07/2007 14:35, "Tom Francais" <tjf at Princeton.EDU>
>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Try appending the log using double greater-than symbols
>>>> in a
>>>>>>>> shell script.
>>>>>>>>>>>>
>>>>>>>>>>>> Example:
>>>>>>>>>>>>
>>>>>>>>>>>> date >> /var/log/jamf.log
>>>>>>>>>>>>
>>>>>>>>>>>> Tom
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On 7/3/07 4:53 AM, "Daniel Farnworth" wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> 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>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> The information contained in this communication is intended
>>>>>>>> solely for the use
>>>>>>>>> of the individual or entity to whom it is addressed and others
>>>>>>>> authorised to
>>>>>>>>> receive it. It may contain confidential or legally privileged
>>>>>>>> information. If
>>>>>>>>> you are not the intended recipient you are hereby notified
>>>> that
>>>>>>>> any
>>>>>>>>> disclosure, copying, distribution or taking any action in
>>>>>>>> reliance on the
>>>>>>>>> contents of this information is strictly prohibited and may be
>>>>>>>> unlawful. If
>>>>>>>>> you have received this communication in error, please notify
>>>>>>>>> postmaster at thecreativepartnership.co.uk immediately and then
>>>>>>>> delete this email
>>>>>>>>> from your system. Any views or opinions presented in this
>>>> email
>>>>>>>> are solely
>>>>>>>>> those of the author and do not necessarily represent those of
>>>>>>>> The Creative
>>>>>>>>> Partnership. The Creative Partnership has taken every
>>>>>>>> reasonable precaution to
>>>>>>>>> ensure that any attachment to this e-mail has been swept for
>>>>>>>> viruses. However,
>>>>>>>>> The Creative Partnership cannot accept liability for any
>>>> damage
>>>>>>>> sustained as a
>>>>>>>>> result of software viruses and would advise that you carry out
>>>>>>>> your own virus
>>>>>>>>> checks before opening any attachment.
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> Casper mailing list
>>>>>>>>> Casper at list.jamfsoftware.com
>>>>>>>>> http://list.jamfsoftware.com/mailman/listinfo/casper
>>>>>>>>> _______________________________________________
>>>>>>>>> Casper mailing list
>>>>>>>>> Casper at list.jamfsoftware.com
>>>>>>>>> http://list.jamfsoftware.com/mailman/listinfo/casper
>>>>>>>>
>>>>>>>> --
>>>>>>>> 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>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> The information contained in this communication is intended
>>>>>>>> solely for the use of the individual or entity to whom it is
>>>>>>>> addressed and others authorised to receive it. It may contain
>>>>>>>> confidential or legally privileged information. If you are not
>>>>>>>> the intended recipient you are hereby notified that any
>>>>>>>> disclosure, copying, distribution or taking any action in
>>>>>>>> reliance on the contents of this information is strictly
>>>>>>>> prohibited and may be unlawful. If you have received this
>>>>>>>> communication in error, please notify
>>>>>>>> postmaster at thecreativepartnership.co.uk immediately and then
>>>>>>>> delete this email from your system. Any views or opinions
>>>>>>>> presented in this email are solely those of the author and do
>>>> not
>>>>>>>> necessarily represent those of The Creative Partnership. The
>>>>>>>> Creative Partnership has taken every reasonable precaution to
>>>>>>>> ensure that any attachment to this e-mail has been swept for
>>>>>>>> viruses. However, The Creative Partnership cannot accept
>>>>>>>> liability for any damage sustained as a result of software
>>>>>>>> viruses and would advise that you carry out your own virus
>>>> checks
>>>>>>>> before opening any attachment.
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Casper mailing list
>>>>>>>> Casper at list.jamfsoftware.com
>>>>>>>> http://list.jamfsoftware.com/mailman/listinfo/casper
>>>>>>>
>>>>>>> Jack E. Bishop
>>>>>>> Network Engineer
>>>>>>> NINDS(Contractor)
>>>>>>> bishopja at mail.nih.gov
>>>>>>> 301.435.2923
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> The information contained in this communication is intended
>>>>>> solely
>>>>>> for the use of the individual or entity to whom it is addressed
>>>> and
>>>>>> others authorised to receive it. It may contain confidential or
>>>>>> legally privileged information. If you are not the intended
>>>>>> recipient you are hereby notified that any disclosure, copying,
>>>>>> distribution or taking any action in reliance on the contents of
>>>>>> this information is strictly prohibited and may be unlawful. If
>>>> you
>>>>>> have received this communication in error, please notify
>>>>>> postmaster at thecreativepartnership.co.uk immediately and then
>>>> delete
>>>>>> this email from your system. Any views or opinions presented in
>>>>>> this email are solely those of the author and do not necessarily
>>>>>> represent those of The Creative Partnership. The Creative
>>>>>> Partnership has taken every reasonable precaution to ensure that
>>>>>> any attachment to this e-mail has been swept for viruses.
>>>>>> However,
>>>>>> The Creative Partnership cannot accept liability for any damage
>>>>>> sustained as a result of software viruses and would advise that
>>>> you
>>>>>> carry out your own virus checks before opening any attachment.
>>>>>
>>>>> Jack E. Bishop
>>>>> Network Engineer
>>>>> NINDS(Contractor)
>>>>> bishopja at mail.nih.gov
>>>>> 301.435.2923
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> The information contained in this communication is intended solely
>>>> for the use of the individual or entity to whom it is addressed and
>>>> others authorised to receive it. It may contain confidential or
>>>> legally privileged information. If you are not the intended
>>>> recipient you are hereby notified that any disclosure, copying,
>>>> distribution or taking any action in reliance on the contents of
>>>> this information is strictly prohibited and may be unlawful. If you
>>>> have received this communication in error, please notify
>>>> postmaster at thecreativepartnership.co.uk immediately and then delete
>>>> this email from your system. Any views or opinions presented in
>>>> this email are solely those of the author and do not necessarily
>>>> represent those of The Creative Partnership. The Creative
>>>> Partnership has taken every reasonable precaution to ensure that
>>>> any attachment to this e-mail has been swept for viruses. However,
>>>> The Creative Partnership cannot accept liability for any damage
>>>> sustained as a result of software viruses and would advise that you
>>>> carry out your own virus checks before opening any attachment.
>>>>
>>>
>>> Jack E. Bishop
>>> Network Engineer
>>> NINDS(Contractor)
>>> bishopja at mail.nih.gov
>>> 301.435.2923
>>>
>>>
>>>
>>>
>
> --
> 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>
>
>
>
>
>
> The information contained in this communication is intended solely
> for the use of the individual or entity to whom it is addressed and
> others authorised to receive it. It may contain confidential or
> legally privileged information. If you are not the intended
> recipient you are hereby notified that any disclosure, copying,
> distribution or taking any action in reliance on the contents of
> this information is strictly prohibited and may be unlawful. If you
> have received this communication in error, please notify postmaster at thecreativepartnership.co.uk
> immediately and then delete this email from your system. Any views
> or opinions presented in this email are solely those of the author
> and do not necessarily represent those of The Creative Partnership.
> The Creative Partnership has taken every reasonable precaution to
> ensure that any attachment to this e-mail has been swept for
> viruses. However, The Creative Partnership cannot accept liability
> for any damage sustained as a result of s
> oftware viruses and would advise that you carry out your own virus
> checks before opening any attachment.
>
> _______________________________________________
> Casper mailing list
> Casper at list.jamfsoftware.com
> http://list.jamfsoftware.com/mailman/listinfo/casper
More information about the Casper
mailing list