Explain this line of code please

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • despdan
    V.I.P. Member
    • Dec 2008
    • 544

    #1

    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
  • red devil
    DK Veteran
    • Oct 2008
    • 690

    #2
    Originally posted by despdan
    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

    Comment

    • Mjolinor
      V.I.P. VIC
      • Jan 2009
      • 1093

      #3
      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

      Comment

      • despdan
        V.I.P. Member
        • Dec 2008
        • 544

        #4
        Originally posted by red devil
        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

        Comment

        • beady
          Junior Member
          • Jul 2008
          • 27

          #5
          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; 23 June, 2009, 00:12.

          Comment

          • Mjolinor
            V.I.P. VIC
            • Jan 2009
            • 1093

            #6
            Originally posted by beady
            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.

            Comment

            Working...