Visit Our UNIX and Linux User Community


input URL into cmd with a alias


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers input URL into cmd with a alias
# 1  
Old 05-10-2011
input URL into cmd with a alias

I want to run
Code:
wget "URL" -SO /dev/null 2>&1 | grep "HTTP/\\|Age:\\|Last-Modified:"

but I want a alias so I can just type mywget and the URL and it will put the url in the right place and give me the output that I want without having to type that over and over again.Smilie

I am newbie to all of this stuff and learning as I go. Any help on this would be great!!

Thank you!!

I want the output to look like this
wget -SO /dev/null http://furiousfanboys.com/wp-content...ling-lucky.jpg 2>&1 | grep "HTTP/\\|Age:\\|Last-Modified:"
HTTP/1.1 200 OK
Last-Modified: Thu, 02 Dec 2010 23:03:08 GMT

This files doesn't have a age header so it doesn't show.

I don't want this:
wget -SO /dev/null http://furiousfanboys.com/wp-content...ling-lucky.jpg
--03:13:55-- http://furiousfanboys.com/wp-content...ling-lucky.jpg
=> `/dev/null'
Resolving furiousfanboys.com... 216.45.60.202
Connecting to furiousfanboys.com|216.45.60.202|:80... connected.
HTTP request sent, awaiting response...
HTTP/1.1 200 OK
Date: Tue, 10 May 2011 10:13:55 GMT
Server: Apache/2.2.15 (Unix) mod_ssl/2.2.15 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 mod_fcgid/2.3.5
Last-Modified: Thu, 02 Dec 2010 23:03:08 GMT
ETag: "16a8020-f944-496756cd3c300"
Accept-Ranges: bytes
Content-Length: 63812
Keep-Alive: timeout=1, max=50
Connection: Keep-Alive
Content-Type: image/jpeg
Length: 63,812 (62K) [image/jpeg]

100%[==================================================================================================== =======>] 63,812 --.--K/s

03:13:55 (1.39 MB/s) - `/dev/null' saved [63812/63812]

I want to be able to type
mywget http://furiousfanboys.com/wp-content...ling-lucky.jpg

and the out put be:
HTTP/1.1 200 OK
Last-Modified: Thu, 02 Dec 2010 23:03:08 GMT

putting the alias in bash is easy but I have no idea how to do this.

hope you like the photo

Last edited by splitradius; 05-10-2011 at 07:24 AM.. Reason: more explanation
# 2  
Old 05-11-2011
which shell are you using?

Also, you can make a script that will handle this:
Code:
#!/bin/bash
wget "$1" -SO /dev/null 2>&1 | grep "HTTP/\\|Age:\\|Last-Modified:"

then run: script.sh URL
# 3  
Old 05-12-2011
kalak,

Thank you for replying, after some research and asking a local guru, he gave me the same thing and it works perfectly!!
Thanks again!
 

Previous Thread | Next Thread
Test Your Knowledge in Computers #148
Difficulty: Easy
A free derivative of BSD Unix, 1992BSD, was released in 1992 and led to the NetBSD and FreeBSD projects.
True or False?

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

passing input into a cmd line that's waiting for a response

Hi, I am writing a little script to update a parameters on JMQ. however the JMQ requires a "y" confirmation to be input as part of the cmd I am running. However I want run this script to offline with no input from a user. it works if a I create a file with with just y in it and pass that in... (3 Replies)
Discussion started by: shropshirehobbi
3 Replies

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

4. Shell Programming and Scripting

run cmd based on input

Hi, This is what I have so far but it seems like a lot more than is necessary because....for example...user presses 2 or 3 ..... the script does the *same* thing it just depends on the directory it has to access....how can I improve this so that the code from 2 and 3 is only put once...? ... (4 Replies)
Discussion started by: holyearth
4 Replies

5. Shell Programming and Scripting

How to input the return value (1 or 0) ping cmd to a variable

Hi I would like to ask about my plan script I have this several workstation want to monitor and execute a command without logging it we use "rsh $host "<command>" i create csh script using foreach to loop my several workstation, my problem with the rsh command is if it encounter a... (3 Replies)
Discussion started by: jao_madn
3 Replies

6. Shell Programming and Scripting

Unix cmd prompt how to get old cmd run?

Hi, I am using SunOS I want to serch my previous command from unix prompt (like on AIX we can search by ESC -k) how to get in SunOs urgent help require. (10 Replies)
Discussion started by: RahulJoshi
10 Replies

7. Programming

How to take input from cmd line into file

Hi, I want to be able to write a simple program that takes in input from the command line. I;m am at the level of getchar and putchar. Any examples would be a great help thanks. I intend/prefer also to use the pipe command | eg: input | file1 ---------- Post updated at 04:08 PM ----------... (4 Replies)
Discussion started by: metros
4 Replies

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

9. Shell Programming and Scripting

ksh: cmd output to input of another script

I want to write a script in KSH that takes the output of one command and redisplays it. Something like: while true do read inpt date +"%I:%M:%S %p <-> $inpt" done and then some how get the output of the ping command to redirect to the input of this script. does that make sense? (2 Replies)
Discussion started by: IMTheNachoMan
2 Replies

10. Shell Programming and Scripting

unix question: user supplied input for 'alias'

I have a program to scan the log files and I want to pipe the output to 'less'. I want to create an alias such that following are equivalent scanlog chunky.lst = /udd/n2man/utils/scanlog chunky.lst|less where chunky is user supplied file which can change. Is this possible as an alias or... (1 Reply)
Discussion started by: ospreyeagle
1 Replies

Featured Tech Videos