Solved

Polling a URL for string from Shell Script

Posted on 2000-04-20
4
381 Views
Last Modified: 2013-12-26
I need to know if the following is possible, and how to accomplish it:

I have a script running on a webserver that returns a string (Ex: "Status=GOOD, Name=Cam")
I want to call this URL from a shell script so that I can parse the string for the values of the variables.

Can someone help?

0
Comment
Question by:camough
  • 2
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
jonalee earned 100 total points
Comment Utility
I think the normal sh, csh will not have this function. You can try to use perl. It has socket function. Http is just 80 port. So, open a 80 port connnection, then (I assume that your script is called 1.cgi) send the string:
Get /path/1.cgi\n\n

Then read from the socket, you will get what you need.
0
 

Author Comment

by:camough
Comment Utility
I am assuming that I would further have to parse the data to exclude typical HTML tags, etc. ?
0
 
LVL 2

Expert Comment

by:jonalee
Comment Utility
No, you do not need, unless you also want this output be viewed by IE or netscape.
If not, you just use this CGI script to simply output the data you want, no need to write the HTML head (Since that head is only useful to IE kind of web browser)

For example:
You 1.cgi here:

#!/usr/bin/perl

print "Status=GOOD";


0
 

Author Comment

by:camough
Comment Utility
I think you may have misunderstood the original question:

I want to call a webpage - either html, cgi, asp, ... whatever, and be able to read in to my unix shell script, whatever the data is that the web script spits out.

0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
mixString challenge 36 98
Add content to output file 4 57
Detect CR LF to each line 12 137
has22 challenge 11 70
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now