0

The script (edited down):

#!/bin/bash
echo Pausify
cd /Users/Ken
echo Pausify finished

The result:

kens-mbp:TerraTouchNate Ken$ tools/pausify.sh tablet.gcode tab3.gcode
Pausify
: No such file or directoryd: /Users/Ken
Pausify finished
kens-mbp:TerraTouchNate Ken$ pwd
/Users/Ken/Dropbox/TerraTouchNate

So how can cd be saying there's no /Users/Ken? I've tried with /bin/sh and /bin/bash, and with other very real directories, selfsame result. Is there some deep magic here?

Joymaker
  • 813
  • 1
  • 9
  • 23
  • Try `\cd` in case `cd` is actually an alias. – bishop Mar 10 '16 at 20:12
  • What happens if you try `cd /Users/Ken` from the command line? – JNevill Mar 10 '16 at 20:25
  • If you were getting this error from the `cd` builtin from `/bin/bash`, you'd get this: `cd: /Users/Ken: No such file or directory`. But it would also be preceded by the script name and line number. There's something you're not telling us. – miken32 Mar 10 '16 at 20:26
  • Also, check the mode on the target directory (`ls -ld /Users/Ken`). It could be that it does not have read permission enabled, but does have execute permission, which would allow you to specify files within the directory if you know the name, but not look to see what the contents are. See `man 1 chmod` and its description for the modes for more details. – Greg Tarsa Mar 10 '16 at 20:27
  • show ouput of `/bin/ls -ld /Users /Users/Ken` Good luck. – shellter Mar 10 '16 at 20:38
  • 1
    The "confused" error message formatting is the clue here. The problem is DOS line endings in the script. (The error should look like what miken32 showed, it doesn't because the carriage-return is causing the output to wrap oddly.) – Etan Reisner Mar 10 '16 at 20:50
  • since you're currently located in /Users/Ken/Dropbox/TerraTouchNate, try to run: cd ../.. in order to get to /Users/Ken and see if you manage to do it and then run: pwd – yorammi Mar 10 '16 at 20:50
  • Chepner, Reisner, You were right. The directory was fine, the cd command was fine, it was all about mysterious DOS line endings lurking in the text. Easily solved by deleting and reinserting all line endings using TextEdit. – Joymaker Mar 10 '16 at 21:44
  • There was deep magic: the lurking hazards of porting a script from Windows to Mac. SOLVED. – Joymaker Mar 10 '16 at 21:56

0 Answers0