Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

babbler

macrumors member
Original poster
Apr 15, 2006
41
0
I have an applescript which contains the line:

-- runs the command system_profiler and grabs the relevant result line
set AirPort to (do shell script "system_profiler |grep 'Current Wireless Network:'").

It works perfectly when run directly from the script editor and when exported as an app. I put it into cron (via cronnix) and when cron tries to run it, it fails with a message roughly "could not find command system_profiler". If I run it from cronixx - by choosing 'run now' again it works perfectly.

Picture1-1.png


Any ideas why cron cannot run the shell script.

Thanks

(Incidentally, the purpose of the line is to find out where the macbook is and run a backup if it is in the office, but not elsewhere. It is a slightly sledgehammer approach to finding which wireless network I am attached to, any better ideas ?)
 

MongoTheGeek

macrumors 68040
I have an applescript which contains the line:

-- runs the command system_profiler and grabs the relevant result line
set AirPort to (do shell script "system_profiler |grep 'Current Wireless Network:'").

It works perfectly when run directly from the script editor and when exported as an app. I put it into cron (via cronnix) and when cron tries to run it, it fails with a message roughly "could not find command system_profiler". If I run it from cronixx - by choosing 'run now' again it works perfectly.

Any ideas why cron cannot run the shell script.

When its run by cron its run in a different user's process. The paths aren't initialized in the same way.

try this
set AirPort to (do shell script "/usr/sbin/system_profiler |grep 'Current Wireless Network:'").
 

babbler

macrumors member
Original poster
Apr 15, 2006
41
0
When its run by cron its run in a different user's process. The paths aren't initialized in the same way.

try this
set AirPort to (do shell script "/usr/sbin/system_profiler |grep 'Current Wireless Network:'").

Thanks. That did it.

I thought it must be a problem with the path to system_profiler, but I could not find it. Searching for system_profiler in Finder does not locate it. How could/should I have found it?


Thanks again
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.