LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 07-24-2011, 08:38 PM   #1
ninja master
Member
 
Registered: May 2008
Distribution: gentoo amd64 xwrt
Posts: 407

Rep: Reputation: 30
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

Last edited by ninja master; 02-21-2012 at 07:11 PM.
 
Old 07-24-2011, 10:37 PM   #2
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,439

Rep: Reputation: 1879Reputation: 1879Reputation: 1879Reputation: 1879Reputation: 1879Reputation: 1879Reputation: 1879Reputation: 1879Reputation: 1879Reputation: 1879Reputation: 1879
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.
 
Old 02-21-2012, 07:05 PM   #3
ninja master
Member
 
Registered: May 2008
Distribution: gentoo amd64 xwrt
Posts: 407

Original Poster
Rep: Reputation: 30
curl supports moar protocol than wget......
 
Old 02-21-2012, 07:26 PM   #4
uhelp
Member
 
Registered: Nov 2011
Location: Germany, Bavaria, Nueremberg area
Distribution: openSUSE, Debian, LFS
Posts: 205

Rep: Reputation: 43
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to execute a shell script (with source command)???? kebabbert Programming 9 11-21-2010 11:06 AM
how to execute Source command in a shell script UltraSoul Linux - General 3 09-23-2010 10:13 AM
perl script system() only execute one command knockout_artist Programming 4 11-11-2008 10:57 AM
Command would not execute within a script pramka Suse/Novell 2 07-16-2008 10:11 AM
How to execute a command line in a shell script orgazmo Programming 5 05-09-2005 09:16 AM


All times are GMT -5. The time now is 10:29 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration