Results 1 to 3 of 3

Thread: Script Syntax Help

  1. #1
    Join Date
    Jan 2011
    Beans
    2

    Script Syntax Help

    Hi im new to these forums so Hello!!! =)

    Im just starting to learn to script and I need to know what this doesnt work, heres the error I get

    "chmond: command not found"
    The error goes away when I delete the line with "dirname $NAME" in it.

    please any help, iv been searching the net for about 2 hours now!

    ----------
    #!/bin/sh

    echo "enter file name with extension and path"
    read NAME

    FULLPATH=`dirname $NAME`
    OPENFILE="open "$NAME
    OPENPATH="open "$FULLPATH
    echo $OPENFILE > /Users/admin/Desktop/tmpLink
    echo $OPENPATH >> /Users/admin/Desktop/tmpLink
    chmond +x /Users/admin/Desktop/tmpLink
    -----------

  2. #2
    Join Date
    Nov 2009
    Location
    East Anglia
    Beans
    417
    Distro
    Xubuntu

    Re: Script Syntax Help

    Quote Originally Posted by ZeroOzzy View Post
    Hi im new to these forums so Hello!!! =)

    Im just starting to learn to script and I need to know what this doesnt work, heres the error I get

    "chmond: command not found"
    The error goes away when I delete the line with "dirname $NAME" in it.

    please any help, iv been searching the net for about 2 hours now!

    ----------
    #!/bin/sh

    echo "enter file name with extension and path"
    read NAME

    FULLPATH=`dirname $NAME`
    OPENFILE="open "$NAME
    OPENPATH="open "$FULLPATH
    echo $OPENFILE > /Users/admin/Desktop/tmpLink
    echo $OPENPATH >> /Users/admin/Desktop/tmpLink
    chmond +x /Users/admin/Desktop/tmpLink
    -----------
    You've got an extra "n" in there, the line should be:
    Code:
    chmod +x /Users/admin/Desktop/tmpLink
    H

  3. #3
    Join Date
    Feb 2007
    Beans
    4,045
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Script Syntax Help

    On a pragmatic and semantic note, you should use lowercase variable names, quote the expansions in double-quotes (" ") and use $( ) instead of backquotes, ` `. I strongly recommend reading http://mywiki.wooledge.org/BashGuide. It's the only really good guide for bash and POSIX sh scripting; The vast majority of scripting guides and tutorials on the net will teach you malpractice.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •