bash about url existence


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting bash about url existence
# 1  
Old 03-04-2010
bash about url existence

Hi,
I want to make a bash script which is running like :
1.sh http://www. google.com

and check if the url does exist printing a message.

I want to save the source code of this page in a file.

Could you help me ?
# 2  
Old 03-04-2010
Code:
WEBSITE="http://my.website.com/"
wget "${WEBSITE}" -O /path/to/saved/file || echo "Couldn't contact ${WEBSITE}"

# 3  
Old 03-04-2010
thanks for your code

I would like to give the url as a parameter with 1.sh
and the temporary file to create the script if there is url.

I have to write -- >

if [ $@ > 0 ]
then

??
# 4  
Old 03-04-2010
Code:
#!/bin/sh

if [ $# -ne 2 ]
then
        echo "$0 Needs 2 parameters"
        exit 1
fi

if wget --quiet "$1" -O "$2"
then
        echo "$1 exists"
        exit 0
else
        echo "$1 could not be retrieved"
        exit 1
fi

# 5  
Old 03-04-2010
thanks again!!
it's what I want exactly
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reading URL using Mechanize and dump all the contents of the URL to a file

Hello, Am very new to perl , please help me here !! I need help in reading a URL from command line using PERL:: Mechanize and needs all the contents from the URL to get into a file. below is the script which i have written so far , #!/usr/bin/perl use LWP::UserAgent; use... (2 Replies)
Discussion started by: scott_cog
2 Replies

2. UNIX for Dummies Questions & Answers

Awk: print all URL addresses between iframe tags without repeating an already printed URL

Here is what I have so far: find . -name "*php*" -or -name "*htm*" | xargs grep -i iframe | awk -F'"' '/<iframe*/{gsub(/.\*iframe>/,"\"");print $2}' Here is an example content of a PHP or HTM(HTML) file: <iframe src="http://ADDRESS_1/?click=5BBB08\" width=1 height=1... (18 Replies)
Discussion started by: striker4o
18 Replies

3. Shell Programming and Scripting

Extracting anchor text and its URL from HTML files in BASH

Hi All, I have some HTML files and my requirement is to extract all the anchor text words from the HTML files along with their URLs and store the result in a separate text file separated by space. For example, <a href="/kid/stay_healthy/">Staying Healthy</a> which has /kid/stay_healthy/ as... (3 Replies)
Discussion started by: shoaibjameel123
3 Replies

4. Shell Programming and Scripting

Bash Script to Find the status of URL

#!/bin/bash timevar=`date +%d-%m-%Y_%H.%M.%S` #-- > Storing Date and Time in a Variable get_contents=`cat urls.txt` #-- > Getting content of website from file. Note the file should not contain any http:// as its already been taken care of echo "Datae-time URL Status code Report" >... (2 Replies)
Discussion started by: anishkumarv
2 Replies

5. Programming

Bash Script to Find the status of URL

#!/bin/bash timevar=`date +%F_”%H_%M”` #-- > Storing Date and Time in a Variable get_contents=`cat urls.txt` #-- > Getting content of website from file. Note the file should not contain any http:// as its already been taken care of ######### Next Section Does all the processing ######### for i... (0 Replies)
Discussion started by: anishkumarv
0 Replies

6. Shell Programming and Scripting

bash script for testing existence of files/folders and creating if neither exist

Hi, I am new to shell-scripting, and doing a lot of reading. I am having some trouble getting started with a simple testing of scripting. I have been experimenting with if, loops, for, test, etc., but still unsure. I seem to have the hang of it when it comes to creating a single file or... (6 Replies)
Discussion started by: me2
6 Replies

7. Web Development

Regex to rewrite URL to another URL based on HTTP_HOST?

I am trying to find a way to test some code, but I need to rewrite a specific URL only from a specific HTTP_HOST The call goes out to http://SUB.DOMAIN.COM/showAssignment/7bde10b45efdd7a97629ef2fe01f7303/jsmodule/Nevow.Athena The ID in the middle is always random due to the cookie. I... (5 Replies)
Discussion started by: EXT3FSCK
5 Replies

8. Shell Programming and Scripting

bash curl escape & in url

I'm running a curl command in bash, but the & in the middle causes the second half of the line to run in the background, here's what I'm trying to do: lat="37.451" lon="-122.18" url="http://ws.geonames.org/findNearestAddress?lat=$lat&lng=$lon" curl -s "$url" I tried escaping the & with \&,... (4 Replies)
Discussion started by: unclecameron
4 Replies

9. Shell Programming and Scripting

url calling and parameter passing to url in script

Hi all, I need to write a unix script in which need to call a url. Then need to pass parameters to that url. please help. Regards, gander_ss (1 Reply)
Discussion started by: gander_ss
1 Replies

10. UNIX for Advanced & Expert Users

url calling and parameter passing to url in script

Hi all, I need to write a unix script in which need to call a url. Then need to pass parameters to that url. please help. Regards, gander_ss (1 Reply)
Discussion started by: gander_ss
1 Replies
Login or Register to Ask a Question