Register
Results 1 to 6 of 6
  1. #1
    V.I.P. Member despdan's Avatar
    Join Date
    Dec 2008
    Location
    Midlands Ireland
    Posts
    544
    Thanks Thanks Given 
    1
    Thanks Thanks Received 
    15
    Thanked in
    2 Posts

    Default Explain this line of code please

    Now I know the first bit goto this address & get filename it's the -O filename 2> /dev/null bit I don't know what exactly it does.

    Code:
    wget -q http://webaddress/filename -O  filename 2> /dev/null

  2. #2
    DK Veteran
    Join Date
    Oct 2008
    Posts
    690
    Thanks Thanks Given 
    0
    Thanks Thanks Received 
    0
    Thanked in
    0 Posts

    Default

    Quote Originally Posted by despdan View Post
    Now I know the first bit goto this address & get filename it's the -O filename 2> /dev/null bit I don't know what exactly it does.

    Code:
    wget -q http://webaddress/filename -O  filename 2> /dev/null

    have a look here Of Zeros and Nulls

  3. #3
    V.I.P. VIC
    Mjolinor's Avatar
    Join Date
    Jan 2009
    Location
    Burnley Vicshire
    Posts
    1,073
    Thanks Thanks Given 
    49
    Thanks Thanks Received 
    114
    Thanked in
    70 Posts

    Default

    the "-O" should be "-o" it just defines the output file name. And by piping the output to NULL you are telling it to be quiet about it, you won't see any screen output, it throws it away

  4. #4
    V.I.P. Member despdan's Avatar
    Join Date
    Dec 2008
    Location
    Midlands Ireland
    Posts
    544
    Thanks Thanks Given 
    1
    Thanks Thanks Received 
    15
    Thanked in
    2 Posts

    Default

    Quote Originally Posted by red devil View Post
    have a look here Of Zeros and Nulls
    Thanks red just what i was looking for

    I was following another tut but skipped over little things like -f -0 -s & you just know there the things that need explaining

  5. #5
    Junior Member
    Join Date
    Jul 2008
    Posts
    27
    Thanks Thanks Given 
    0
    Thanks Thanks Received 
    0
    Thanked in
    0 Posts

    Default

    the "-O" should be "-o" it just defines the output file name. And by piping the output to NULL you are telling it to be quiet about it, you won't see any screen output, it throws it away
    Not really true. "-o" defines where the logfile is written to, while "-O" specifies a file to save to. So the original command save the file "http://webaddress/filename" to the local file "filename", and discards any output generated from the "wget" program itself (which would usually get sent to stderr, which will default to the terminal, as described in the link posted by red devil). You can get pretty much the same effect by using
    Code:
    wget http://webaddress/filename -O filename -o /dev/null
    in which you have specified that logging goes to the /dev/null device (i.e. is thrown away).
    Overall though, the purpose of the command is to download a file from t'internet silently, without any text being sent to a terminal.

    edit: Actually, it's already "quiet" because of the "-q" option, so if successful, nothing will be displayed on the terminal. However, in the event of an error, like the url being invalid or a more serious error, the "2 > /dev/null" makes sure nothing is displayed.
    Last edited by beady; 23rd June, 2009 at 12:12 AM.

  6. #6
    V.I.P. VIC
    Mjolinor's Avatar
    Join Date
    Jan 2009
    Location
    Burnley Vicshire
    Posts
    1,073
    Thanks Thanks Given 
    49
    Thanks Thanks Received 
    114
    Thanked in
    70 Posts

    Default

    Quote Originally Posted by beady View Post
    Not really true. "-o" defines where the logfile is written to, while "-O" specifies a file to save to. So the original command save the file "http://webaddress/filename" to the local file "filename", and discards any output generated from the "wget" program itself (which would usually get sent to stderr, which will default to the terminal, as described in the link posted by red devil). You can get pretty much the same effect by using
    Code:
    wget http://webaddress/filename -O filename -o /dev/null
    in which you have specified that logging goes to the /dev/null device (i.e. is thrown away).
    Overall though, the purpose of the command is to download a file from t'internet silently, without any text being sent to a terminal.

    edit: Actually, it's already "quiet" because of the "-q" option, so if successful, nothing will be displayed on the terminal. However, in the event of an error, like the url being invalid or a more serious error, the "2 > /dev/null" makes sure nothing is displayed.
    Yup, my bad. Apologies.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.