wget won't from script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting wget won't from script
# 1  
Old 01-24-2010
wget won't from script

I am trying to use wget to capture a web page on the Internet.
If I use the command from a terminal like:
wget Whidbey Island, Naval Air Station WA Weather -O /tmp/FIL.tmp
it works but if I use it in a bash script the size of /tmp/FIL.tmp is zero.
Can someone help me. Should I not be using wget in a script? Seems like if it works from a terminal it should work from a script. This is Slackware's recent version and the script is root priv.
# 2  
Old 01-24-2010
What type of script? Perl? PHP? KSH? Bash?

Please post the code. Thanks.
# 3  
Old 01-24-2010
From a terminal or a script is just an interface but the base command ' wget ' remains the same. There is no reason for it to refuse working when executed with other set of commands in a string. It will work. Smilie

Post us what is there in the script that you have tried.
# 4  
Old 01-24-2010
Sorry, thought wget being bash command was enough but yes it is BASH
# 5  
Old 01-24-2010
Can you try with the full path to wget? Use:

/usr/bin/wget -q <link> -O /tmp/FIL.tmp
# 6  
Old 01-24-2010
wget won't from script

OK! think I have the solution.
Here is the script:
Code:
    # User defines this source page location
    SRCLOC=`egrep SRCLOC DATFIL | cut -d" " -f2`  <--- (1)
    echo SRCLOC=$SRCLOC
    SRCLOC=`echo $SRCLOC | cut -d"\"" -f2`  <--- (2)
    echo SRCLOC=$SRCLOC
    SRCLOC=`echo $SRCLOC | cut -d"\"" -f1`  <--- (3)
    echo SRCLOC=$SRCLOC
    # Extract page from internet to /tmp/FIL.tmp
    wget $SRCLOC -O /tmp/FIL.tmp

After you all queried me I trimmed the code and got an unsupported scheme for SRCLOC.
I discovered that my script was inserting double quotes when only line 1 was used.
When manually done:
SRCLOC="whatever the URL is"
of course the double quotes go away.
Adding lines 2 & 3 removed the double quotes and the script runs OK!
Adding /usr/bin would be superfluous as it is in my PATH.
Thanks ALL!

Last edited by pludi; 01-25-2010 at 02:08 AM.. Reason: code tags, please...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Bash script won't run because hardware won't produce display

Can anyone offer any advice on how to modify the script below to work on a new system we have, that has no graphics capability? We admin the system through a serial RAS device. I've tried running the below script through the RAS and through an ssh -X session. It failed with something like "GTK... (3 Replies)
Discussion started by: yelirt5
3 Replies

2. 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

3. Shell Programming and Scripting

Script won't fails when running from crontab

Hi, My script runs fine from the command line, but when crontab tries to launch it encounters lack of permissions: could not open /dev/kbd to get keyboard type US keyboard assumed could not get keyboard type US keyboard assumed split: Permission denied This is the head of the script: ... (2 Replies)
Discussion started by: Cvg
2 Replies

4. UNIX for Dummies Questions & Answers

A very simple script, but alias won't work

I am new to unix and therefore I did a lot of reading before posting. So please, if this has been answered before, forgive me for re-posting and point me to the right place for the answer. I have spent many hours searching the net and read over 50 posts in this forum and even tried a few thing but... (20 Replies)
Discussion started by: sssccc
20 Replies

5. Shell Programming and Scripting

bash script won't execute (Mac)

I can't get any bash scripts to run in Terminal (Mac - Snow Leopard). I have the following super-simple script, and I can't get it to execute despite having the correct permissions (I think). #!/bin/bash echo "WORK... PLEASE?!" I named the file 'testScript.sh', and I added execution... (6 Replies)
Discussion started by: compulsiveguile
6 Replies

6. AIX

won't mount /usr...won't boot fully

Hello: NOOB here. I attempted to use smit mkcd. Failed on first attempt, not enough space. 2nd attempt tried to place iso on /usr, not enough space there. Cleanup ran for about 5 minutes after aborting. Now AIX won't boot. LCD display on 7029-6E3 says: 0517 MOUNT /USR. Attempted to boot from CD... (11 Replies)
Discussion started by: bbird
11 Replies

7. UNIX for Dummies Questions & Answers

2 ftps in script, second won't go to output file

I'm running this on both solaris and hp boxes, ftping from windows, then ftping to an aix machine. If I run the ftpReportFile by itself, I get info in the ftp_rpt_log. If I run just the 2 ftps together, I also get output. However, if I run the entire shell script, I don't get output from... (4 Replies)
Discussion started by: brdholman
4 Replies

8. UNIX for Dummies Questions & Answers

Made command into a script but now won't run

Hello, After seeing in a Unix cheatsheet that I could add commands into a file and run that file as a command to save on typing, i tried it with this: #! /bin/csh # Backup website excluding directories that do not change rsync -e "ssh -p 2222" -axzvc --progress --stats --compress-level=9... (9 Replies)
Discussion started by: patwa
9 Replies

9. Shell Programming and Scripting

scp output fm script won't go to file

Have a script that scp's tar file to multiple other servers in a for loop. Need to set monitoring and notification on it for when it fails. Running this line of code in a 'for' loop... scp $SOURCE_RECOVERY_TARFILE ${HOST}:${CURR_RECOV_TARFILE} 2>&1 | tee ${MONFILE} Their are two outputs... (7 Replies)
Discussion started by: nmikes
7 Replies

10. UNIX for Dummies Questions & Answers

Why won't my script run?

On the following script that I get an error when I try to execute as root: #./mv_log.sh bash: /root/util/mv_log.sh: Permission denied #!/usr/bin datetag=`date --date='1 day ago' +"%b%d%Y"` logname=`find /opt/bea/wlserver6.1/config/*/logs/ -iname 'access.log0*' -mtime -1 -print` mv... (4 Replies)
Discussion started by: darthur
4 Replies
Login or Register to Ask a Question