LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   script execute command problem (http://www.linuxquestions.org/questions/linux-newbie-8/script-execute-command-problem-893539/)

ninja master 07-24-2011 09:38 PM

script execute command problem
 
i would like to create a script that calls a command with a flag....

/usr/bin/wget

calling

"curl -O"

-------------------------------answering my own post-----------------------------------
sudo su

cat > /usr/bin/wget << EOF
#!/bin/bash
curl -O $1
EOF
chmod 750 /usr/bin/wget
exit

the real question is this script properly written, and if not how would a more proper writing of this script look

grail 07-24-2011 11:37 PM

I would have said the real question is why would you try to recreate wget when it already exists and may already be on your system so this may actually cause a conflict.

As to whether or not it will work ... the old adage of suck it and see looks good for such a short non-impacting script.

ninja master 02-21-2012 08:05 PM

curl supports moar protocol than wget......

uhelp 02-21-2012 08:26 PM

The use of "<<EOF" is pointless.
Unless one want to type more than needed.
The single "cat > DoNotNameAnyScriptLikeAnExistingCommand" does the trick. (If finished give it the EOF with ^d meaning <ctrl><d> )

Code:

#!/bin/bash

outFile="-O $1"  #prepares the option -O
shift            # shifts away the URL

curl "$*" "$outFile"

with this script you can use it like intended "NOTwget URL" or use all the other options curl takes as well.


All times are GMT -5. The time now is 07:57 PM.