0

i have a bash script i would like modify to support input from shell atm i have to type the link after i have run the script

wiak@test:~$ scripts/lget.sh
gimme cookie!
https://raw.github.com/nwgat/scripts/master/lget.sh
80 bytes transferred
done.
wiak@test:~$

like this input from shell

lget https://github.com/nwgat/scripts/raw/master/lftp.sh

the bash script

echo "gimme cookie!"
read down
lftp -e 'pget -n 5 '$down' && exit'
echo "done."

its also here on github if someone wants to fork it https://github.com/nwgat/scripts/blob/master/lget.sh

software needed to make it work: lftp http://lftp.yar.ru/

1

Try this:

echo "gimme cookie!"
#read down
lftp -e 'pget -n 5 '$1' && exit'
echo "done."

Now you can pass the link as a command line option. $1 expands to the first command line option you pass to your shell script.

  • so that is how that worked, thx for the help – nwgat Mar 9 '14 at 22:17
  • Yes :) You're most welcome. I am glad to have been of help. – Ghassan Mar 9 '14 at 22:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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