I am very new to bash scripting but have learned a lot over the past several days. I was given this script that uses a program called mc2xml to download adn xml file that then gets loaded into EyeTV. My problem is the path in the cd commads thinks the path starts with ers instead of /Users. Also the ping command recieved no packets. These commands work fine if I enter them directly into Terminal.
Script:
#!/bin/bash
MC2XML="/Users/ericphil2/Scripts/mc2xml"
XMLTV="/Users/ericphil2/Scripts/xmltv.xml"
#Set the working directory
cd /Users/ericphil2/Scripts
#Check for internet connection
ping -q -c 1 -t 5 google.com
if [ $? -eq 0 ]; then
#Get new schedule
$MC2XML -J -c us -g 14519
#Reload EyeTV with the file
echo "in if statement"
open -a EyeTV $XMLTV
fi
Here is the response from Terminal:
[MacPro:~/Scripts] ericphil2% sh ./test2.sh
Hello World
/Users/ericphil2/Scripts/mc2xml
/Users/ericphil2/Scripts/xmltv.xml
: No such file or directoryers/ericphil2/Scripts
PING google.com\013 (198.105.244.228): 56 data bytes
--- google.com\013 ping statistics ---
1 packets transmitted, 0 packets received, 100.0% packet loss
./test2.sh: line 18: syntax error: unexpected end of file
[MacPro:~/Scripts] ericphil2% sh ./test2.sh
: No such file or directoryers/ericphil2/Scripts
PING google.com\013 (198.105.244.228): 56 data bytes
--- google.com\013 ping statistics ---
1 packets transmitted, 0 packets received, 100.0% packet loss
./test2.sh: line 15: syntax error: unexpected end of file
[MacPro:~/Scripts] ericphil2%