I'm brand new to Applescript and also have some limited experience with Terminal. I made simple shell script today that I saved on my desktop. It's named "Test.sh" and just copies a file from one folder to another. When I run sh ~/Desktop/Test.shfrom within Terminal, everything runs just fine. However, when I type do shell script "/Volumes/volume_name/Users/username/Desktop/Test.sh" inside Xcode as an Applescript command, nothing happens. I am using Xcode 4.4.1 on Mac OS 10.7.4 (though I guess it's irrelevant). What am I missing?
1
votes
3 Answers
2
votes
0
votes
Let us consider that the applescript you want to run inside the shell script is to empty the trash. Follow these steps:
- Open Terminal
- type "touch sample.sh" and press return
- Type "chmod +x sample.sh" and press return
- Type "open -e sample.sh" and press return, this open text editor
- Paste the below code in text file and save it.
!/bin/bash
osascript -e 'tell application "Finder" empty trash end tell'
- Go back to terminal. Type "./sample.sh". this will result in empty trash.
chmod +x Test.sh) ? - Paul Rchmod: Test.sh: No such file or directory. I changedTest.shto~/Desktop/Test.sh, but now it only waits for another command, without doing anything. What am I supposed to see as a result? - Gepapado