I have this basic script in bash:
SOFT=apt-fast
FILE=$SOFT.sh
PATH=$SRCF/$FILE
WWW=http://www.mattparnell.com/linux/apt-fast/$FILE
EXEC=/usr/bin/apt-fast
wget -v -U firefox $WWW -O $PATH
mv $PATH $EXEC
The rendered开发者_运维百科 code (with the debugging turned on) is as follows:
SOFT=apt-fast
+ SOFT=apt-fast
FILE=$SOFT.sh
+ FILE=apt-fast.sh
PATH=$SRCF/$FILE
+ PATH=/home/rgr/src/apt-fast.sh
WWW=http://www.mattparnell.com/linux/apt-fast/$FILE
+ WWW=http://www.mattparnell.com/linux/apt-fast/apt-fast.sh
EXEC=/usr/bin/apt-fast
+ EXEC=/usr/bin/apt-fast
wget -v -U firefox $WWW -O $PATH
+ wget -v -U firefox http://www.mattparnell.com/linux/apt-fast/apt-fast.sh -O /home/rgr/src/apt-fast.sh
cleanstart.sh: line 132: **wget: command not found**
mv $PATH $EXEC
+ mv /home/rgr/src/apt-fast.sh /usr/bin/apt-fast
cleanstart.sh: line 133: **mv: command not found**
exit
+ exit
I have tried almost everything... What foolish mistake am I making here? The script is beeing called like this:
sudo bash -vx script.sh
#-v for verbose and -x for turning debug mode on
Thanks.
This one is easy :> its because you override the "PATH" variable. that is of course the one the system needs in order to find the location of "wget" iteself.
:>
You've deleted your path with
PATH=$SRCF/$FILE
leaving only that one something/something value in there.
The path environment variable tells the shell where it should look for executables, and you've toasted it.
Use a different variable name to handle your urls for wget.
One of the variables in your script is called PATH
. PATH
is also the name of the special variable used to find executables.
Using another variable name should fix your problem.
精彩评论