Open-AudIT

What's on your network?
It is currently Sun Jan 21, 2018 11:10 am

All times are UTC + 10 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Tue Apr 08, 2014 12:31 am 
Offline
Newbie

Joined: Wed Apr 02, 2014 10:50 pm
Posts: 7
Hi Guys,

Huge welldone and thanks to the open-audit team, has made me life so much easier.

The only problem I seem to have is below. When I run the osx script as root manually it works fine. When I add it to cron to run weekly, I get the following errors

Cron Daemon root@rr0152.local
1:50 PM (56 minutes ago)

to macadmin
System Info
/var/root/audit_osx.sh: line 27: system_profiler: command not found
/var/root/audit_osx.sh: line 28: networksetup: command not found
/var/root/audit_osx.sh: line 33: system_profiler: command not found
/var/root/audit_osx.sh: line 34: system_profiler: command not found
/var/root/audit_osx.sh: line 40: system_profiler: command not found
expr: syntax error
/var/root/audit_osx.sh: line 42: sysctl: command not found
Network Cards Info
/var/root/audit_osx.sh: line 121: system_profiler: command not found
/var/root/audit_osx.sh: line 138: system_profiler: command not found
Processor Info
/var/root/audit_osx.sh: line 145: sysctl: command not found
/var/root/audit_osx.sh: line 147: sysctl: command not found
sudo: system_profiler: command not found
(standard_in) 1: parse error
Memory Info
/var/root/audit_osx.sh: line 203: system_profiler: command not found
Software Info
/var/root/audit_osx.sh: line 260: system_profiler: command not found
Submitting results to server
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed

0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
100 1131 0 0 100 1131 0 401 0:00:02 0:00:02 --:--:-- 400
100 1803 100 672 100 1131 200 338 0:00:03 0:00:03 --:--:-- 338
100 1803 100 672 100 1131 200 338 0:00:03 0:00:03 --:--:-- 338
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<head>
<title>Open-AudIT</title>
</head>

<body>
<a href='http://open-audit.internal.*.com/index.php/system'>Back to input page</a><br />
<a href='http://open-audit.internal.*.com/index.php'>Front Page</a><br />
SystemID (updated): <a href='http://open-audit.internal.*.com/index.php/main/system_display/29'>29</a>.<br />
<br />Time: 0.9408 seconds.</body>
</html>cat: illegal option -- 2
usage: cat [-benstuv] [file ...]
rm: illegal option -- 2
usage: rm [-f | -i] [-dPRrvW] file ...
unlink file

script is located here /var/root/audit_osx.sh with following file premissions

rwxr-x--- 1 root staff 11K 2 Apr 11:47 audit_osx.sh

I can run the script by doing /var/root/audit_osx.sh but fails if it's in a crontab


RR0152:~ root# crontab -l
MAILTO="macadmin@*.com"

50 13 * * * /var/root/audit_osx.sh

machine is a mac mini running 10.9 aka mavericks. The audit is showing up as running under the device in the web interface.
59 - audit 2014-04-07 14:49:06 192.168.10.127 2014-04-07 14:48:27



I have also tried this on couple of other machines and get the same error.


Top
 Profile  
Reply with quote  
PostPosted: Tue Apr 08, 2014 1:21 am 
Offline
Moderator

Joined: Fri Jul 20, 2007 8:27 am
Posts: 1226
I don't use MacOS or Linux much but from your crontab entry it looks like you're using a user crontab entry. So I would say that whatever user you're running the task under doesn't have access to all the commands which give you errors.


Top
 Profile  
Reply with quote  
PostPosted: Tue Apr 08, 2014 6:54 pm 
Offline
Newbie

Joined: Wed Apr 02, 2014 10:50 pm
Posts: 7
I very much doubt it, I logged in as root and run command then run crontab -e as root.


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 09, 2014 1:17 am 
Offline
Moderator

Joined: Fri Jul 20, 2007 8:27 am
Posts: 1226
Maybe something up with $PATH when run from cron?


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 09, 2014 8:41 pm 
Offline
Newbie

Joined: Wed Apr 02, 2014 10:50 pm
Posts: 7
If I run the command from command line
e.g system_profiler SPHardwareDataType | grep "Serial Number (system):" | cut -d":" -f2 | sed 's/^ *//g'`
It works fine giving me the result I expected. I tried to move it to a normal user and run again as cronjob, same error. I changed the system_profiler to have the full path e.g /usr/sbin/system_profiler SPHardwareDataType | grep "Serial Number (system):" | cut -d":" -f2 | sed 's/^ *//g'` but still get the same error? any one got any ideas as I'm stuck!


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 10, 2014 3:03 am 
Offline
Site Admin
User avatar

Joined: Mon Jun 07, 2004 11:48 am
Posts: 1933
Location: Brisbane, Australia
Looks to me like a permission error - but from what you said that "shouldn't" be the case.
Anyone more familiar with OSX than me? (I'm not very).

_________________
Support and Development hours available from Opmantek.
Please consider a purchase to help make Open-AudIT better for everyone.


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 17, 2014 7:45 pm 
Offline
Newbie

Joined: Wed Apr 02, 2014 10:50 pm
Posts: 7
Any one any ideas, still got the same problem! :(


Mark are you able to try it on your mac, i guess you have tested the new osx script?


Top
 Profile  
Reply with quote  
PostPosted: Thu Jun 19, 2014 8:34 am 
Offline
Site Admin
User avatar

Joined: Mon Jun 07, 2004 11:48 am
Posts: 1933
Location: Brisbane, Australia
I've not run it using cron - I'll make a note to myself to test it.

_________________
Support and Development hours available from Opmantek.
Please consider a purchase to help make Open-AudIT better for everyone.


Top
 Profile  
Reply with quote  
PostPosted: Thu Jun 19, 2014 10:55 pm 
Offline
Newbie

Joined: Wed Apr 02, 2014 10:50 pm
Posts: 7
Found the problem and fixed it.

When run as root it can find system_profiler but when run as crontab it can't, so You can either change all the lines to be /usr/sbin/system_profiler "not sure if same location on all osx versions, it is on 10.9.2 and 10.7.5

or I added "export PATH=$PATH:/usr/sbin" to start of script, works fine now.


Top
 Profile  
Reply with quote  
PostPosted: Fri Jun 20, 2014 7:32 am 
Offline
Site Admin
User avatar

Joined: Mon Jun 07, 2004 11:48 am
Posts: 1933
Location: Brisbane, Australia
Thanks pw98 - I have added this to the script.

_________________
Support and Development hours available from Opmantek.
Please consider a purchase to help make Open-AudIT better for everyone.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC + 10 hours


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group