#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2011
    Posts
    107
    Rep Power
    3

    How to execute shell script without doing /bin/sh ?


    Hi. I created a simple script to ssh to a server so I don't need to remember the ip.

    file: ssh-server
    content:
    #!/bin/sh

    ssh root@127.0.0.1

    Please ignore the ip, it's just an example.

    If I just run it "ssh-server" it will returns command not found. I even rename the file to ssh-server.sh but still the same.

    Is there a way I can run the script without putting /bin/sh at the beginning? I just want to type less that's all and see if it's possible?

    Thanks.
  2. #2
  3. No Profile Picture
    I haz teh codez!
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2003
    Posts
    2,540
    Rep Power
    2337
    Make the file executable.
    If it already is, then give the full path to the file, or add the directory containing the file to your PATH.
    If you're in the directory where the file is located, and it's executable, use ./ssh-server.
    I ♥ ManiacDan & requinix

    This is a sig, and not necessarily a comment on the OP:
    Please don't be a help vampire!
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2011
    Posts
    107
    Rep Power
    3
    Originally Posted by ptr2void
    Make the file executable.
    If it already is, then give the full path to the file, or add the directory containing the file to your PATH.
    If you're in the directory where the file is located, and it's executable, use ./ssh-server.
    Thank you!

IMN logo majestic logo threadwatch logo seochat tools logo