The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Call shell script from php not run ? raccsdl Shell Programming and Scripting 2 11-19-2007 08:21 AM
To call/execute a shell script from a shell script konark UNIX for Dummies Questions & Answers 1 10-26-2007 05:16 PM
how can i call a shell script from pl/sql rajesh.P Shell Programming and Scripting 3 09-16-2007 11:09 PM
how can a call shell script from pl/sql rajesh.P UNIX for Dummies Questions & Answers 0 09-14-2007 02:42 AM
How to call a shell script from awk ? Amruta Pitkar Shell Programming and Scripting 1 04-20-2007 04:35 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-18-2007
chengwei chengwei is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 30
URL call from SHELL script

My system does not have wget, curl and lynx. The chances are low that the SA would install them for me. Do I have any other way out? I need to invoke a few URL calls from my SHELL script.

Thought of using a PERL script or writing a simple Java client, but that adds in more dependencies.

Any idea?
  #2 (permalink)  
Old 04-18-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,507
if you have Python, you can use it's urllib2 library
Code:
#!/usr/bin/python
import urllib2
page = urllib2.urlopen("http://www.google.com")
result = page.read()
open("output.html","w").write(result) # write to output.html
  #3 (permalink)  
Old 04-18-2007
chengwei chengwei is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 30
Sorry, how do I know if I've python installed? Actually I just need to invoke an URL, thats all, no need to output it to a file.
  #4 (permalink)  
Old 04-18-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,507
you can type
# which python

or

# find / -name "python*".
  #5 (permalink)  
Old 04-18-2007
cbkihong cbkihong is offline Forum Advisor  
Advisor
  
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,624
For Perl, preferably LWP module is used for HTTP.

But for plain vanilla HTTP, if you can't really install LWP (note that you can download and install the module together with the script and not install it systemwide), a simple sequence of commands will do it:

Code:
use IO::Socket::INET; 
$http = IO::Socket::INET->new(
    PeerAddr => "www.unix.com:80",
    Proto => "tcp"
);
$http->print("GET /showthread.php?t=37182 HTTP/1.0\nHost: www.unix.com\n\n"); 
print $http->getlines();
which will display the HTML for this page. IO::Socket::INET is shipped standard with Perl, so you cannot say it is an "external dependency".
  #6 (permalink)  
Old 04-18-2007
chengwei chengwei is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 30
My URL call is actually invoking a servlet call. I don't really need to display any HTML. So does it mean that I should just omit this line of code?

Code:
print $http->getlines();
  #7 (permalink)  
Old 04-18-2007
chengwei chengwei is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 30
Quote:
Originally Posted by ghostdog74
you can type
# which python

or

# find / -name "python*".

Unfortunately for me, Python is also not installed. Guess I'll have to use Perl then. Thanks!
Sponsored Links
Closed Thread

Bookmarks

Tags
solaris

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:24 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0