Source bash script from Applescript
Hey all,
So have a question about sourcing a file.sh script from applescript.
Currently I have the following bash script I made for upon entering a DVD it rips and encodes with HandbrakeCLI. Which when I call it with ./HBcli.sh it runs and works perfectly fine. I do have it as executable too with: chmod +x HBcli.sh
------------------------------------------------------------------
#!/bin/sh
# Get title of DVD
DVD_TITLE=$(df -h | grep dev/disk3 | grep Volumes | awk '{print $9}' | cut -c10-90)
FILE=$DVD_TITLE
SRC=$(df -h | grep dev/disk3 | grep Volumes | awk '{print $9}')
DEST=~/Desktop/Converted
HB_PRESET='--preset="Normal"'
HB=HandBrakeCLI
#echo $DEST/$FILE.mp4
#echo $HB_PRESET
$HB -i $SRC -o $DEST/$FILE.m4v $HB_PRESET
------------------------------------------------------------------
Now I have the Applescript that is set up like so:
------------------------------------------------------------------
--Tried this first
tell application "Finder"
do shell script "./HBcli.sh" -- or "do shell script "source HBcli.sh"
end tell
-----------------------------------------------------------------
I then proceeded to try it all via Applescript without the script itself
---------------------------------------------
tell application "Finder"
set DVD_TITLE to do shell script "df -h | grep dev/disk3 | grep Volumes | awk '{print $9}' | cut -c10-90"
set theFile to DVD_TITLE as string
set SRC to do shell script "df -h | grep dev/disk3 | grep Volumes | awk '{print $9}'"
set DEST to "~/Desktop/Converted" as string
set HB to "/opt/homebrew-cask/Caskroom/handbrakecli/0.10.2/HandBrakeCLI"
do shell script "" & HB & " " & SRC & " -o " & DEST & "/" & theFile & ".mp4 --preset='normal'"
-- Gave the following error: error "Finder got an error: Missing input device. Run /opt/homebrew-cask/Caskroom/handbrakecli/0.10.2/HandBrakeCLI --help for syntax." number 1
--set HB to "HandBrakeCLI"
--do shell script "" & HB & " " & SRC & " -o " & DEST & "/" & theFile & ".mp4 --preset='normal'"
-- Gave the following error: error "Finder got an error: sh: HandBrakeCLI: command not found" number 127
do shell script "" & HB & " " & SRC & " -o " & DEST & "/" & theFile & ".mp4 --preset='normal'"
end tell
---------------------------------------------
1) What is the proper wait to call the script from Applescript?
2) If I am doing mostly correct, what can I do to correct the issues?
3) Is automated able to pull and use bash scripts also.
Also, if you have any recommendations or methods of creating a script or Applescript.
I run a mini OS X 10.11.1
Mac mini, Other OS, 10.10.4