Need help with shell script

Can you or someone tell me what’s wrong with this simple script / bash?
Name of script is and it is located in /home
The script itself;
#!/bin/bash ----- also try #!/bin/sh
~/home/ u
~$ command not found
~$ hpass
hpass: command not found

1 Like

Can you post the clean script’s contents without the additional stuff? What is the script supposed to do?

1 Like

~/home/ u

I know it sound lazy, but I was trying to learn something too.
Instead of typing in terminal mode ‘sudo ~home/ u’,
I wanted to just type ‘hpass’. The ‘u’ is a parm being pass to ‘’.
The command will unlock my WD external disk. It works fine, if I type it in with sudo in front of it.

1 Like

that’s not lazy at all. learning something new is the opposite of lazy in my book :slight_smile:

1 Like

as we have talked about, i don’t know anything about python. i do see one thing here:

your u needs a - in front of it = -u

then my question is whether or not you made your script executable. looks like you named it, so that command should look something like chmod +x ~/

1 Like

I’d suggest you need to preface calling your script with the path to the script, assuming $HOME is not on your $PATH - you have to explicitly tell it “run this script from this location” - with “./” - or “~/” - and also what somebody else suggested - make sure it’s executable “chmod +x ./”…

Also - most shells automatically append ~/bin/ onto your path if it exists - so make a folder ~/bin, copy the script there… if you want to ignore the .sh when you call it - make a symlink to the script “ln -s ~/bin/ ~/bin/hpass”. You may have to log out and back in again if ~/bin didn’t exist and isn’t in your $PATH… once all that’s done - you can just type “hpass” as your shell now knows where to find that…

1 Like

alternatively - you could also create an alias to the python script -
alias hpass="~/home/ u"

when you’re happy with that, assuming bash is your main shell (mine is zsh) then edit your ~/.bashrc and put that alias line at the end…

then all you have to do is type “hpass”…
— edit —
I just noticed something - you’re quoting “~/home/” is this true?

e.g. if your username is “easyt50”… is there a “/home/easyt50/home” folder ? Does this path exist? Maybe it should just be :


or "/home/easyt50/"


Here again, I need some guidance. I don’t know any of the shell names or how many there are.
I need to walk (do something simple) first, before I run (writing something complex).
So I am willing to work with any shell. I would just like to use one that is easy to learn to start with.
For the time being, I want to write simple scripts to replace typing in a command or multi commands to help me use the PC.

1 Like

Yes, I missed type the command. A ‘-’ is required in front of the ‘u’. Thanks for noticing it.
I did the chmod and now when I edit the file, I get ‘hpass’ is an executable file.
I am still getting command not found when I type hpass in terminal mode.

1 Like

you probably have to add the “./” before you type the command :

e.g. “./hpass” (or “./”)

1 Like

Thanks for your suggestions. I believe I am at /home. If I do a dir, I can see my file ‘’.
I tried both way to exec the command (’./’ and ‘~/’ on front of ‘’.

easyt50@8300 ~ $ ./
./ line 2: /home/easyt50/home/ No such file or directory

easyt50@8300 ~ $ ~/
/home/easyt50/ line 2: /home/easyt50/home/ No such file or directory

Thanks Daniel, I just learn how to set up an alias and (look up) how to unalias. But that did not work either.

No, that file (dir) is not there. The path to the file is /home/easyt50/

But I believe I see what you mean. ‘home’ is showing up too much, but I don’t know how to correct it.

1 Like

Bingo! :grinning: ‘./’ got the script to execute. It did not pick up the -u. So now I need to play around with passing a parm to the command from inside the script. I had to change the script by taking ‘home’ out of it. So the script now looks like this. Not the ‘*’, only the 3 lines.

~/ -u

1 Like

When working directory is home than command must be


Thanks for your input and welcome to our community - hope you enjoy your stay with us