volna
volna

Reputation: 2610

do shell script results in command not found

I've found sh-script for CPU Throttling and would like to schedule it on startup using AppleScript in the following way:

do shell script "sudo /Users/BohdanAir/Documents/Automation/cputhrottler.sh" "password mypassword" with administrator privileges

And get the following error:

error "sudo: /Users/BohdanAir/Documents/Automation/cputhrottler.sh: command not found" number 1

P.S: The pass provided to the sh file is being fully copied from the Get Info option (CDM + I)

Upvotes: 1

Views: 1003

Answers (1)

user3439894
user3439894

Reputation: 7555

Not even sure how you received that error message when the do shell script command shown in your question does not even compile.

The "password mypassword" portion actually has to be password "mypassword" for it to compile.

The reason you're getting:

error "sudo: /Users/BohdanAir/Documents/Automation/cputhrottler.sh: command not found" number 1

Is because cputhrottler.sh is not set as executable.

Make it executable using the following command:

chmod u+x /Users/BohdanAir/Documents/Automation/cputhrottler.sh

This will allow it to execute and not throw that particular error message.

Or use the following convention:

do shell script "sh /Users/BohdanAir/Documents/Automation/cputhrottler.sh" password "mypassword" with administrator privileges

Note that sudo was replaced with sh, or use other shell. In this manner the shell script does not need to be made executable.

Upvotes: 1

Related Questions