Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Trickle is a bandwidth limiting program. I have the following script for trickle.

#!/bin/bash
echo $PATH
trickle -s -t 3 -u 200 -d 200 "$@"

I have a script in ~/bin/ that want to run the script with. I

$ my_trickle.sh new_script.sh
/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/local/sbin:/usr/local/bin:/usr/games:~/bin
trickle: exec(): No such file or directory

It works if I run my_trickle.sh ~/bin/new_script.sh

Why isn't trickle recognizing the $PATH correctly? Can I get it to locate new_script.sh located in ~/bin/?

share|improve this question
1  
The ~ character is expanded to be your home directory in certain contexts; occurrences in the middle of a shell variable's contents is not one of them. In whatever init file sets and exports PATH, replace that ~/bin with $HOME/bin –  Mark Plotnick Feb 10 at 9:32
    
@Mark Plotnick Hey, that fixed it. I changed ~/bin to $HOME/bin in my bashrc file. Cheers. –  Rucent88 Feb 10 at 9:54
    
@MarkPlotnick or Rucent88 could one of you post that as an answer please? –  terdon Feb 10 at 16:04
    
Done. Also, correction to my comment: ~ will be expanded if it's right after an unquoted colon and the contents are being used in an assignment. So maybe the PATH assignment in bashrc used quotes. In any case, $HOME will be expanded even when it's inside double quotes. –  Mark Plotnick Feb 10 at 16:38

2 Answers 2

According to the shell standards document, tilde expansion is supposed to take place when a shell variable is assigned if the tilde is at the beginning of a word or follows an unquoted colon.

So it's a bit unusual for a raw tilde to wind up in the middle of your PATH variable:

/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/local/sbin:/usr/local/bin:/usr/games:~/bin

But it is there, and the shell is not going to expand it to be your home directory when it looks through PATH to find an executable.

The easiest fix is to change ~ to $HOME in whatever init file sets PATH. I'd guess there are some double quotes in that statement that are preventing ~ from getting expanded.

share|improve this answer

Change ~/bin to $HOME/bin the file that sets $PATH.

Probably your ~/.bashrc or ~/.profile

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.