0

the problem I have is the following, I recently installed Ubuntu and was setting up a map where I could collect all my scripts. The map I use is the bin folder on the location:

/home/myusername/bin

But now when I try to execute the script from my home folder it doesn't work: sh: 0: Can't open test.sh.

Does anyone have an idea why this is?

3
  • If you walk us through the steps you took to try to set this up and the behavior expected, it will be easier to help you get this set up.
    – Danny Dyla
    Mar 22, 2013 at 10:08
  • I had a nice picture of a command box with the code I used step by step but I couldn't upload it because my reputation was too low :D Mar 22, 2013 at 10:17
  • Usually if you link a picture from imgur or similar and it is actually helpful, someone with the correct reputation will edit your post to make the image viewable. You could also just copy it into your buffer and use the <$> tool in the editor to add it.
    – Danny Dyla
    Mar 22, 2013 at 10:21

2 Answers 2

0

Open your /home/username/.bashrc file and add the following string:

alias command_name='/path/to/script'

for example you want to create a commmand named test1 and the script is in /home/your_user/scripts/test.sh so you just write in /home/your_user/.bashrc

alias test1 = '/home/your_user/scripts/test.sh

Hope this will work.

2
  • it works but it is however not really what I'm looking for. if I use this method I will have to add an alias every time I add a new script. I was looking to make one map where I can throw everything in and just execute from there. is this possible in any way shape or form ? Mar 22, 2013 at 9:40
  • Then try to put your scripts in /usr/bin or /usr/sbin and relogin in terminal. This should work.
    – Ivan
    Mar 22, 2013 at 9:45
0

Add your bin folder to the $PATH, or call the script as ./bin/myscript.

1
  • I got it to work! (from the /home/myusername/bin folder) apparantly when executing a script from a folder you do it with test.sh instead of sh test.sh Mar 22, 2013 at 10:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .