Wget ouput to log file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Wget ouput to log file
# 1  
Old 07-04-2014
Wget ouput to log file

Hi all

The following code will update the Dynamic DNS server at Namecheap.com.
Code:
wget -O 'https://dynamicdns.park-your-domain.com/update?host=www&domain=example.com&password=your DDNS password'

Would like to append the output to a log file using
Code:
 >> /path/path/logfile

at the end of the command.

So is it necessary to include the '-O' parameter in the command string?

TIA
# 2  
Old 07-04-2014
What happened when you tried it with and without the -O flag?



Robin
# 3  
Old 07-04-2014
rbatte1

Thanks for your reply.

Without '-O'
Code:
--2014-07-04 16:34:25--  https://dynamicdns.park-your-domain.com/update?host=www&domain=mysite.com&password=9736b76370874a8797bc7426f66b8165
Resolving dynamicdns.park-your-domain.com (dynamicdns.park-your-domain.com)... 199.188.202.39
Connecting to dynamicdns.park-your-domain.com (dynamicdns.park-your-domain.com)|199.188.202.39|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 234 [text/html]
Saving to: `update?host=www&domain=mysite.com&password=9736b76370874a8797bc7426f66b8165'

100%[======================================>] 234         --.-K/s   in 0s      

2014-07-04 16:34:26 (66.5 MB/s) - `update?host=www&domain=mysite.com&password=9736b76370874a8797bc7426f66b8165' saved [234/234]

but no output to the log file

With '-O'
Code:
wget: missing URL
Usage: wget [OPTION]... [URL]...

Try `wget --help' for more options.

but no output to the log file.

So either way, no output to the local log file.

Removing
Code:
 >> /path/path/logfile

makes no difference to what is returned.
# 4  
Old 07-04-2014
Reading the manual page for wget it suggests that there are options for -o & -O

Quote:
-o logfile
Log all messages to logfile. The messages are normally reported to standard error.
- - or - -
Quote:
-O file
The documents will not be written to the appropriate files, but all will be concatenated together and written to file. If - is
used as file, documents will be printed to standard output, disabling link conversion. (Use ./- to print to a file literally
named -.)

Use of -O is not intended to mean simply "use the name file instead of the one in the URL;" rather, it is analogous to shell
redirection: wget -O file http://foo is intended to work like wget -O - http://foo > file; file will be truncated immediately, and
all downloaded content will be written there.

For this reason, -N (for timestamp-checking) is not supported in combination with -O: since file is always newly created, it will
always have a very new timestamp. A warning will be issued if this combination is used.

Similarly, using -r or -p with -O may not work as you expect: Wget won't just download the first file to file and then download
the rest to their normal names: all downloaded content will be placed in file. This was disabled in version 1.11, but has been
reinstated (with a warning) in 1.11.2, as there are some cases where this behavior can actually have some use.

Note that a combination with -k is only permitted when downloading a single document, as in that case it will just convert all
relative URIs to external ones; -k makes no sense for multiple URIs when they're all being downloaded to a single file.
Have you got the right one? Try lower case and give it a file-name to work with, something like:-
Code:
wget -o /tmp/my_log_file 'https://dynamicdns.park-your-domain.com/update?host=www&domain=example.com&password=your DDNS password'

Does that help?




Robin

Last edited by rbatte1; 07-04-2014 at 01:43 PM.. Reason: Changing "’" for an apostrophe
This User Gave Thanks to rbatte1 For This Post:
# 5  
Old 07-05-2014
Using
Code:
wget -o /tmp/my_log_file ...

produces
Code:
--2014-07-05 06:59:52--  https://dynamicdns.park-your-domain.com/update?host=@&domain=mysite.com&password=9736b76370874a8797bc7426f66b8165
Resolving dynamicdns.park-your-domain.com (dynamicdns.park-your-domain.com)... 199.188.202.39
Connecting to dynamicdns.park-your-domain.com (dynamicdns.park-your-domain.com)|199.188.202.39|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 234 [text/html]
Saving to: `update?host=@&domain=mysite.com&password=9736b76370874a8797bc7426f66b8165'

     0K                                                       100% 54.3M=0s

2014-07-05 06:59:53 (54.3 MB/s) - `update?host=@&domain=mysite.com&password=9736b76370874a8797bc7426f66b8165' saved [234/234]

The use of '-O' came from namecheap.com in response to the question, 'What is the required string, etc"
Quote:
First of all, you need to enable Dynamic DNS (DDNS) for the domain name. You can do it in the following way: log in to your Namecheap account, go to Manage Domains and click on the domain name. Then click on Dynamic DNS at the bottom of the left menu and enable DDNS. After that you will be able to update the IP address using the following command:

wget -O 'https://dynamicdns.park-your-domain.com/update?host=hostname&domain=example.com&password=your DDNS password'

If you need to update the root domain (i.e. 'example.com'), the value of 'host' should be @ (e.g. host=@). If you need to update 'www.example.com', the value should be as follows: host=www. Here are the exapmples for both 'example.com' and 'www.example.com':

wget -O 'https://dynamicdns.park-your-domain.com/update?host=@&domain=example.com&password=your DDNS password'

wget -O 'https://dynamicdns.park-your-domain.com/update?host=www&domain=example.com&password=your DDNS password'

Hope this helps.
I needed to output the result to a log hence the additional code.

Unless you can see anything wrong with the output to the logfile, it seems your suggestion solves the problem?
# 6  
Old 07-07-2014
So is this working as you need it now, or do you need to process the file to extract the information you want?


Robin
# 7  
Old 07-07-2014
Without forcing an IP address change to test the code, it does appear to be correct, and if it fails then Namecheap need to check it out.

Many thanks for your help.
This User Gave Thanks to CRChamberlain For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Wget - working in browser but cannot download from wget

Hi, I need to download a zip file from my the below US govt link. https://www.sam.gov/SAMPortal/extractfiledownload?role=WW&version=SAM&filename=SAM_PUBLIC_MONTHLY_20160207.ZIP I only have wget utility installed on the server. When I use the below command, I am getting error 403... (2 Replies)
Discussion started by: Prasannag87
2 Replies

2. Shell Programming and Scripting

Wget rename file

Is it possible to use a cookie transfer to a location and then rename the output? cd target_directory wget -x --load-cookies cookies.txt http://172.24.188.113/data/getCSV.csv | for file in * do mv $file $file.txt done For example, if I change the directory to C:\test and use the ... (2 Replies)
Discussion started by: cmccabe
2 Replies

3. Shell Programming and Scripting

Inserting ouput into a file using redirection

Hallo Team, I would like to redirect an output from a file into another file. Here are the two commands/files. -bash-3.2$ cat lack.csv lemontwistpax -bash-3.2$ ll -ltr BW*|tail -1 -rw-r--r-- 1 mind mind 1844 Sep 25 12:06... (8 Replies)
Discussion started by: kekanap
8 Replies

4. Shell Programming and Scripting

Call a Perl script within a bash script and store the ouput in a .txt file

I'm attempting to write a bash script that will create a network between virtual machines. It accepts three arguments: an RSpec that describes the network topology, and two list of machines (servers and clients). I have a (working) Perl script that I want to call. This Perl script takes an RSpec... (6 Replies)
Discussion started by: mecaka
6 Replies

5. UNIX for Dummies Questions & Answers

wget redirect file name

I am downloading a file using wget and the following is embedded in a script: wget http://www.example.com/ABCDfilename123.txt -O filename123.txt Because the 123 is incremented with every day, I need to pass the file in a parametric manner, so the filename as given after capital D. How do I... (2 Replies)
Discussion started by: figaro
2 Replies

6. Shell Programming and Scripting

View ouput as a file

Hi all , I have a view in teradata , the ouput of that view have to be stored as a file with delimitere as '|'.Is there any possibility of doing this in unix ? Thanks in advance , Vinoth (6 Replies)
Discussion started by: vino.paal
6 Replies

7. Shell Programming and Scripting

Limit ouput file on a shell script

I have this one::) doing jstack on JVM proccess. #!/bin/ksh # ---------------------------------------------------- # capture_jstack.sh <INTERVAL> <COUNT> # run jstack and capture output to a log file #----------------------------------------------------- # # scripts and logs are stored... (3 Replies)
Discussion started by: pointer
3 Replies

8. UNIX and Linux Applications

download file using wget

I need to download the following srs8.3.0.1.standard.linux26_32.tar.gz file from the following website: http://downloads.biowisdomsrs.com/srs83_dist There are many gzip files along with the above one in the above site but I want to download the srs8.3.0.1.standard.linux26_32.tar.gz only from... (1 Reply)
Discussion started by: alphasahoo
1 Replies

9. Shell Programming and Scripting

download a particular file using wget

Hi All I want to download srs8.3.0.1.standard.linux24_EM64T.tar.gz file from the following website : http://downloads.biowisdomsrs.com/srs83_dist/ But this website contains lots of zipped files I want to download the above file only discarding other zipped files. When I am trying the... (1 Reply)
Discussion started by: alphasahoo
1 Replies

10. UNIX for Dummies Questions & Answers

Using wget to download a file

Hello Everyone, I'm trying to use wget recursively to download a file. Only html files are being downloaded, instead of the target file. I'm trying this for the first time, here's what I've tried: wget -r -O jdk.bin... (4 Replies)
Discussion started by: thoughts
4 Replies
Login or Register to Ask a Question