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

joptimus

macrumors regular
Original poster
Oct 7, 2016
135
128
Hi guys,

I have a NAS and I created an app with AppleScriptEditor that automatically mounts my folders on login/startup.
Now I want to run that app when my computer wakes from sleep.
I followed this guide here:
https://www.bluepiccadilly.com/2012...rive-when-your-computer-starts-or-wakes-sleep

Steps 1 and 2 are fine, they work.

But at Step 3.4 I'm stuck. I cannot get the shell script converted to executable. Nothing happens when I follow the commands in terminal - the .sh file just stays like it was before...at least I think so.

When I go to Finder and open the shell script from step 3 with Terminal, the following happens:

Last login: Sat Sep 29 16:29:42 on ttys001
Johannes-Air:~ joptimus_mac$ /Users/joptimus_mac/Documents/Skripte/ConnectOnWake.sh ; exit;
/Users/joptimus_mac/Documents/Skripte/ConnectOnWake.sh: line 2: /bin/sh&: No such file or directory
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
[Prozess beendet]


What does it mean "no such file or directory"? Is the guide wrong?
Thanks for your help!
 
The guide is wrong. The shell script he gives in step 3.1 makes no sense to me.

The escaped & will be appended literally to the pathname of the shell. That's nonsensical on its face, because there isn't a program named "/bin/sh&". Maybe he intended it to be something else, since a trailing & has meaning for the shell, but I can't tell what that intent might be, because that entire script is so unusual.

Echoing a command to a different instance of the shell makes no sense. All you need to do is issue the command in the shell script itself. So the script would contain this line in place of the original command line:
Code:
open ~/Scripts/ConnectToNetworkDrive.app/
If there were spaces or other unusual characters in the pathname, simple quoting would suffice. I can't think of a single relevant reason to pipe the command to another shell.

Sadly, it doesn't look like a live site any more, so I don't think asking the guy who posted it will get too far.

So maybe just try the simplified example above and see what happens. If it fails, you can come back, describe what happened, and we can take it from there.
 
  • Like
Reactions: joptimus
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.