1

I'm new to OSX, and don't use the commandline that often. I'm trying to use a script to do some automatic deployment, but when I execute the script it is looking for a directory.

I tried:

sh myscript.sh '/Users/profiles/Desktop/Development'
sh myscript.sh /Users/profiles/Desktop/Development
sh myscript.sh -/Users/profiles/Desktop/Development

but I keep getting "No Such file or directory". What is the proper way to do this?

I know this is a basic question, but I can't seem to find a simple answer. Everything I find on google is much more advanced..

UPDATE: In the script, it's looking for the path like this:

DIR_DEVELOP=$@

if [ -z $DIR_DEVELOP ]; then
    echo "Syntax: myscript.sh <destination>"
    exit 1
Mircea Vutcovici
  • 17,619
  • 4
  • 56
  • 83
cinqoTimo
  • 247
  • 5
  • 15
  • 1
    Also, what's in your shebang line ( http://en.wikipedia.org/wiki/Shebang_(Unix) )? – msanford Apr 02 '12 at 13:34
  • looks like "!#/bin/bash – cinqoTimo Apr 02 '12 at 14:54
  • Then you don't need to pass the script to `sh` (which is itself a shell) at all as the purpose of the shebang line is to choose an interpreter for the script. Assuming the script has the execute bit set, you can call it like `./myscript.sh '/Users/profiles/Desktop/Development'`. – msanford Apr 02 '12 at 15:13
  • Perhaps another good question for us to ask of you would be *Please show us what your script does when it looks for the path you pass*, because the bug is probably there. I should have started with that question :) – msanford Apr 02 '12 at 15:16
  • @msanford - This is a script that has been in operation for a while, so I know it's not the script, it's me... – cinqoTimo Apr 02 '12 at 17:03
  • @msanford - ./myscript.sh '/Users/profiles/Desktop/Development' still says "No Such File or Directory" – cinqoTimo Apr 02 '12 at 17:03
  • What I meant by my second comment was: would you please post the source code of your script that relates to your path argument (probably a `{$1}` somewhere) just to check. – msanford Apr 02 '12 at 17:17
  • I added that part to my question... – cinqoTimo Apr 02 '12 at 19:36
  • Can you post output of `ls -l myscript.sh` Since you are not reporting seeing any output from `sh -x ...` I'm wondering if the script isn't in the current directory, or maybe there is a problem with the filename such as containing a trailing space character. – Brian Swift Apr 02 '12 at 21:13

2 Answers2

1

You have to enable tracing in bash:

bash -x myscript.sh '/Users/profiles/Desktop/Development'

You will see the "No Such file or directory" message right after the line that generates the error.

Mircea Vutcovici
  • 17,619
  • 4
  • 56
  • 83
0

You don't need to use ' in your path. According to the Advanced Bash Scripting guide:

$@
Same as $*, but each parameter is a quoted string, that is, the parameters are passed on intact, without interpretation or expansion. This means, among other things, that each parameter in the argument list is seen as a separate word.

So the path your script is trying to access is literally '/Users/profiles/Desktop/Development' instead of /Users/profiles/Desktop/Development

Zypher
  • 37,405
  • 5
  • 53
  • 95