0

This is a shell script I am trying to run in a Mac OS 10.14 environment. My initial goal was to have this script run daily by a launch agent. When that wouldn't work I tracked the problem to the shell script itself. I know the paths are correct since I have both typed them myself and tried dragging the directories and files onto the script in Xcode and allowing the editor to build the paths itself. Here is the script:

#!/bin/bash
MC2XML="/Users/ericphil2/Scripts/mc2xml"
XMLTV="/Users/ericphil2/Scripts/xmltv.xml"
#Set the working directory
cd /Users/ericphil2/Scripts
#Get new schedule
    $MC2XML -J -c us -g 14519
#Reload EyeTV with the file
    open -a EyeTV $XMLTV

When I run this I get the following errors:

[MacPro:~/Scripts] ericphil2% sh /Users/ericphil2/Scripts/getepg.sh 
: No such file or directorytepg.sh: line 5: cd: /Users/ericphil2/Scripts
: No such file or directorytepg.sh: line 7: /Users/ericphil2/Scripts/mc2xml
 does not exist.ericphil2/Scripts/xmltv.xml
TryAgain12
  • 31
  • 3
  • Let's see what happens when you run that script without sh. That is, can you make your script executable and then run it? chmod +x getepg.sh ; ./geteph.sh – Mark Feb 19 '19 at 22:51
  • doing that I get ./getepg.sh: Command not found – TryAgain12 Feb 19 '19 at 23:54
  • I am not sure why this has been marked as a duplicate. I looked at the attached link and those questions and answers did not match my question. I have done extensive searching on this site and others for anything similar and have not found an answer. – TryAgain12 Feb 20 '19 at 00:11
  • I think the person marking your question as a duplicate believes the problem to be related to \r at the end of you lines. Try reviewing your script with od -c or better still vim -b. You'll need to take the \r ( or carriage returns ) out of your file if the moderator is correct. You may also do so with 'tr -d \r' I think. – Mark Feb 20 '19 at 14:58
  • Mark, thank you for the clarification. Carriage returns were the problem and the tr line fixed it. Being new to this it was not clear to me in the link that this was the problem and the fix. – TryAgain12 Feb 20 '19 at 22:05
  • you're welcome. The real credit goes to the moderator who identified your problem and marked it as a duplicate. I've had the problem a few times in my career so I recognized the answer when I saw the title. – Mark Feb 22 '19 at 03:29

0 Answers0