When I search for .bashrc files in my system I get:
/etc/bash.bashrc
/etc/skel/.bashrc
/root/.bashrc
/usr/share/base-files/dot.bashrc
I changed:
/etc/bash.bashrc
/root/.bashrc
I added the alias.
alias urldecode='python -c "import sys, urllib as ul; \
print ul.unquote_plus(sys.argv[1])"'
alias urlencode='python -c "import sys, urllib as ul; \
print ul.quote_plus(sys.argv[1])"'
When I run the command:
urlencode 'http://example.com space'
it works OK from the command line, but when I create an .sh
file and put the same command there I get:
./tf.sh: line 19: urlencode: command not found
What is wrong?
Contents of tf.sh
file:
IP=$(curl -d "tool=checurl"-X POST https://site.com/get.py)
url='https://site.com.com/'
path=$(grep -oP '(?<=get.py\?filetype=csv\&data=).*?(?=\")' <<< $IP)
pathfull="get.py?filetype=csv&data=$path"
full=$url$pathfull
#echo $full
urlencode '$full'
tf.sh
.bashrc
in your script and make it interactive withset -i
.