I have a script which tries to verify the existence of a BugID by
making a http::get request to a bug tracking url.
http://tracking.edgetrade.com/default.asp?pg=pgEditBug&command=view&ixBug=9999
typing it in manually returns the expected page (of course) but when i
do it in perl i get the default page only
(http://tracking.edgetrade.com)
what am i doing wrong?
#!/usr/bin/perl
use LWP;
print "verifying BugID...\n";
$logFile = shift @ARGV;
open(LOGFILE, $logFile) or die "Can't verify BugID in CVS commit log
file: $logFile: $!\n";
while ($line = <LOGFILE>) {
print "line: $line\n";
if ($line =~ /\s*Bug[zs]*\s*IDs*\s*[#:; ]+((\d+[ ,:;#]*)+)/i)
{
$bugIDstring .= " " . $1;
}
}
print "BugID's: $bugIDstring\n";
@bugIDlist = split("[ ,:;#]+", $bugIDstring);
$ixBug = 0;
foreach (@bugIDlist)
{
if (/\d+/)
{
$ixBug = int($_);
print "Attempting to verify bug info for Bug ID #$ixBug...\n";
$ua = LWP::UserAgent->new();
$url =
"http://tracking.edgetrade.com/default.asp?pg=pgEditBug&command=view&ixBug=$ixBug";
$webdoc = $ua->request(HTTP::Request->new(GET => $url));
$content = $webdoc->content;
print "$content\n";
if ($content =~ /Case #$ixBug does not exist or has been
deleted./)
{
die "BugID: $ixBug does not exist in FogBugz\n";
}
}
}
|
|
0
|
|
|
|
Reply
|
skijor (4)
|
5/6/2005 6:00:04 PM |
|
Mike Starkie wrote:
> I have a script which tries to verify the existence of a BugID by
> making a http::get request to a bug tracking url.
>
> http://tracking.edgetrade.com/default.asp?pg=pgEditBug&command=view&ixBug=9999
>
> typing it in manually returns the expected page (of course) but when i
Really? When I "type it in manually", I get:
[1] 83664
http://tracking.edgetrade.com/default.asp?pg=pgEditBug: No match.
[2] 83665
ixBug=9999: Command not found.
command=view: Command not found.
[1] - Exit 1
http://tracking.edgetrade.com/default.asp?pg=pgEditBug
:-)
> do it in perl i get the default page only
> (http://tracking.edgetrade.com)
>
> what am i doing wrong?
First, you should provide code can be executed without modification. We
have no idea what's in $logFile. e.g. (based on your code..)
#!/usr/local/bin/perl
use strict;
use LWP;
my $ixBug=999;
print "Attempting to verify bug info for Bug ID #$ixBug...\n";
my $ua = LWP::UserAgent->new();
my $url =
"http://tracking.edgetrade.com/default.asp?pg=pgEditBug&command=view&ixBug=$ixBug";
my $webdoc = $ua->request(HTTP::Request->new(GET => $url));
my $content = $webdoc->content;
print "$content\n";
Second, look at what's returned. Isn't the text "Not Logged On"
helpful? It's asking for authentication, you need to log on to the site,
before you can get to that URL.
Finally, take a look at WWW::Mechanize. It should help you submit your
information to log on, and then to view the bug.
|
|
0
|
|
|
|
Reply
|
J
|
5/6/2005 6:34:26 PM
|
|
Well it certainly is due to the fact that I'm not logged in. How do I
know what the form expects for authentication (it's a POST)? It seems
to me I would have to sniff the wifre to see the post right?
The form expects two inputs a 'User' and 'Password". i wrote this test
script that fails:
#!/usr/bin/perl
use LWP;
my $browser = LWP::UserAgent->new;
my $url = 'http://tracking.edgetrade.com/default.asp?';
my $res = $browser->post($url, [User => "me", Password =>
"mypasswrod"]);
my $content = $res->content;
if($content =~ /Welcome to FogBUGZ/)
{
print "logged on";
}
|
|
0
|
|
|
|
Reply
|
Mike
|
5/6/2005 8:42:05 PM
|
|
Mike Starkie wrote:
> Well it certainly is due to the fact that I'm not logged in. How do I
> know what the form expects for authentication (it's a POST)? It seems
> to me I would have to sniff the wifre to see the post right?
No, simply looking at the correct HTML should be enough.
Ya need to go to the right URL. Selecting "Log On", in the browser
takes me to:
http://tracking.edgetrade.com/default.asp?pg=pgLogon&dest=
View the source to get the names of the fields, and be sure to set the
various hidden variables, you'll also need to store at least one cookie.
Again, do yourself and us a favor and at least read about
WWW::Mechanize. There are examples, and some very nice methods to make
this much easier.
|
|
0
|
|
|
|
Reply
|
J
|
5/6/2005 9:20:28 PM
|
|
J. Gleixner <glex_nospam@qwest.invalid> wrote:
> Mike Starkie wrote:
>> Well it certainly is due to the fact that I'm not logged in. How do I
>> know what the form expects for authentication (it's a POST)? It seems
>> to me I would have to sniff the wifre to see the post right?
>
> No, simply looking at the correct HTML should be enough.
>
> Ya need to go to the right URL. Selecting "Log On", in the browser
> takes me to:
>
> http://tracking.edgetrade.com/default.asp?pg=pgLogon&dest=
>
> View the source to get the names of the fields, and be sure to set the
> various hidden variables, you'll also need to store at least one cookie.
>
> Again, do yourself and us a favor and at least read about
> WWW::Mechanize. There are examples, and some very nice methods to make
> this much easier.
See also
Web Scraping Proxy
http://www.research.att.com/~hpk/wsp/
Which will write the Perl code for you.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
|
|
0
|
|
|
|
Reply
|
Tad
|
5/6/2005 9:45:53 PM
|
|
In article <1115402404.130396.85040@f14g2000cwb.googlegroups.com>,
Mike Starkie <skijor@gmail.com> wrote:
>I have a script which tries to verify the existence of a BugID by
> ...
> $webdoc = $ua->request(HTTP::Request->new(GET => $url));
> $content = $webdoc->content;
> print "$content\n";
> if ($content =~ /Case #$ixBug does not exist or has been
>deleted./)
> {
> die "BugID: $ixBug does not exist in FogBugz\n";
> }
> }
>}
>
In addition to the other answers, you'll normally want to
glean more from the response:
$webdoc = $ua->request(...);
if ($webdoc->is_success) {
print $webdoc->content; }
else {
print "failed: ", $webdoc->status_line; }
hth,
--
Charles DeRykus
#! rnews 1193
Xref: xyzzy comp.unix.programmer:136921
Newsgroups: comp.unix.programmer
Path: xyzzy!nntp
From: "Fred L. Kleinschmidt" <fred.l.kleinschmidt@nospam_boeing.com>
Subject: Re: Folder contents
X-Nntp-Posting-Host: xpc-ps-53.nw.nos.boeing.com
Content-Type: text/plain; charset=us-ascii
Message-ID: <427BE8E4.71D456CB@nospam_boeing.com>
Sender: nntp@news.boeing.com (Boeing NNTP News Access)
Content-Transfer-Encoding: 7bit
Organization: Boeing
X-Accept-Language: en
References: <1115395160.999855.129060@g14g2000cwa.googlegroups.com>
Mime-Version: 1.0
Date: Fri, 6 May 2005 22:00:04 GMT
X-Mailer: Mozilla 4.79 [en]C-CCK-MCD Boeing Kit (Windows NT 5.0; U)
yorkyboy wrote:
>
> Guys im very new to Unix and scripting as a whole, but can anyone tell
> me if its posible to create a script that looks at say 4 folders, then
> checks which has the least amount of files in, then copy a file to that
> folder?.
First, get used to calling them "directories", instead of "folders".
Look at the 'man' pages for ls, wc, and cp (i.e., type "man ls" or "man
wc" etc.)
--
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Common User Interface Services
M/S 2R-94 (206)544-5225
|
|
0
|
|
|
|
Reply
|
ced
|
5/6/2005 9:51:21 PM
|
|
For some reason, this tool does not generate any perl for me. The
website uses asp and the results of using wsp are a few files (w0 - w6)
which contain no perl only html and javascript
|
|
0
|
|
|
|
Reply
|
Mike
|
5/9/2005 6:31:11 PM
|
|
In article <1115663471.848260.112780@f14g2000cwb.googlegroups.com>,
Mike Starkie <skijor@gmail.com> wrote:
> For some reason, this tool does not generate any perl for me. The
> website uses asp and the results of using wsp are a few files (w0 - w6)
> which contain no perl only html and javascript
HTTP::Request does not generate Perl code. It encapsulates an HTTP/GET
request and the response from an HTTP server for some URL. The response
should contain HTML, which can contain javascript code, but that is up
to the server, not your program. Why do you think it should contain
Perl code?
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
|
|
0
|
|
|
|
Reply
|
Jim
|
5/9/2005 6:41:04 PM
|
|
Jim Gibson wrote:
> In article <1115663471.848260.112780@f14g2000cwb.googlegroups.com>,
> Mike Starkie <skijor@gmail.com> wrote:
>
>
>>For some reason, this tool does not generate any perl for me. The
>>website uses asp and the results of using wsp are a few files (w0 - w6)
>>which contain no perl only html and javascript
>
>
> HTTP::Request does not generate Perl code. It encapsulates an HTTP/GET
> request and the response from an HTTP server for some URL. The response
> should contain HTML, which can contain javascript code, but that is up
> to the server, not your program. Why do you think it should contain
> Perl code?
Mike neglected to include information from the post he was referring to
that mentioned "wsp".
Tad McClellan wrote:
> See also
>
> Web Scraping Proxy
>
> http://www.research.att.com/~hpk/wsp/
>
> Which will write the Perl code for you.
As for wsp.pl writing code for you, it took a little looking around, but
I found this:
http://hacks.oreilly.com/pub/h/955#code
Very nice!
|
|
0
|
|
|
|
Reply
|
J
|
5/9/2005 7:22:41 PM
|
|
WooHoo.......sweeeeeet.
>./wsp.pl -v | ./translate.pl > test.pl
>./test.pl
works.....problem solved !!!
for the annals of time:
1: I didn't realize the perl output of wsp is on STDOUT
2: Use Both wsp and translate together to save a ton of time since you
don't have to encode the session by trial and error and piece together
the perl
4: my complaints should include more context so that new joiners on the
thread can understand them.
|
|
0
|
|
|
|
Reply
|
Mike
|
5/9/2005 9:02:36 PM
|
|
Mike Starkie <skijor@gmail.com> wrote:
> For some reason, this tool does not generate any perl for me.
Which tool are you speaking of?
HTTP::Request is a "module", not a "tool", and it isn't _supposed_
to generate any perl.
What made you think that it would generate perl (or Perl, more likely)?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
|
|
0
|
|
|
|
Reply
|
Tad
|
5/10/2005 3:01:41 AM
|
|
these two 'tools' taken together will generate perl:
../wsp.pl -v | ./translate.pl > test.pl
../test.pl
you're the second person that mis-understood me.....sorry.
see links above for tools: wsp and translate
|
|
0
|
|
|
|
Reply
|
Mike
|
5/10/2005 5:48:44 PM
|
|
Mike Starkie <skijor@gmail.com> wrote:
> you're
Who is?
Please quote some context in followups like everybody else does.
> the second person that mis-understood me.....sorry.
That's because you are not quoting context.
And you are *still* not quoting context.
I'm doubting the sincerity of your "sorry" there.
If you were truly sorry you would stop the behavior that led
to the misunderstanding, else it will just happen again.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
|
|
0
|
|
|
|
Reply
|
Tad
|
5/11/2005 5:39:34 AM
|
|
Mike Starkie <skijor@gmail.com> wrote:
> see links above for tools: wsp and translate
There are no "links above", so once again we don't know what
you're talking about.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
|
|
0
|
|
|
|
Reply
|
Tad
|
5/11/2005 5:41:11 AM
|
|
of course you could always read the entire thread instead in order to
clear up your confusion instead of doubting my sincerity.
|
|
0
|
|
|
|
Reply
|
Mike
|
5/11/2005 4:57:53 PM
|
|
Mike Starkie <skijor@gmail.com> wrote:
> of course you could always read the entire thread
Reading the entire thread would not be necessary if you quoted
some context like everybody else does.
You appear to not know much about the propogation of Usenet
articles. It is entirely possible that a followup arrives
*before* the article that it is followup up to.
The original article may even *never* show up. NNTP is not guaranteed.
So, many people don't *have* and entire thread, and they're left
wondering what you're talking about.
> instead in order to
> clear up your confusion instead of doubting my sincerity.
There is no longer any confusion, you've just confirmed
that your apology was indeed insincere.
*plonk*
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
|
|
0
|
|
|
|
Reply
|
Tad
|
5/11/2005 6:55:49 PM
|
|
Actually you are right. There's no need for me to aplogize for you not
understanding my reference to the tool that you suggested in the first
place. My aplogies to others though and to redeem my sincerity I
include some quoted text here:
You wrote:
>See also
> Web Scraping Proxy
>
> http://www.research.att.com/~hpk/wsp/
>
>Which will write the Perl code for you.
then I wrote:
>WooHoo.......sweeeeeet.
>./wsp.pl -v | ./translate.pl > test.pl
>./test.pl
>works.....problem solved !!!
then you wrote:
>Which tool are you speaking of?
then I wrote:
>these two 'tools' taken together will generate perl:
>./wsp.pl -v | ./translate.pl > test.pl
>./test.pl
|
|
0
|
|
|
|
Reply
|
skijor
|
5/11/2005 9:46:57 PM
|
|
skijor@gmail.com <skijor@gmail.com> wrote:
> Actually you are right.
It is rare, but it has been known to happen.
> my reference to the tool that you suggested in the first
> place.
I answer many many questions each day.
I don't remember who I said what to, they all meld together
after a bit of time has passed.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
|
|
0
|
|
|
|
Reply
|
Tad
|
5/11/2005 11:54:02 PM
|
|
|
17 Replies
63 Views
(page loaded in 0.172 seconds)
Similiar Articles: Is it possible to retrieve http response status? - comp.lang ...... possible to use javascript on the browser >> side (Firefox 2) to get the http response ... Help with a sending of a image via HTTP; How to send http post request in ASP; HTTP ... "Microsoft.XMLHTTP = delete request? - comp.lang.javascript ...Reply: oldrich.svec81 (1) 2/11/2008 1:36:20 PM ... A client that doesn't support PUT and DELETE is also likely to not support custom HTTP request ... Identifier Expected Error in JSP page - comp.lang.java.programmer ...Reply: jiali2121 (1) 6/29/2007 2:08:10 AM ... on this>function>public List<String> func()See http ... ERROR: Connect: External table is not in the expected format ... Display PDF from Ajax Response - comp.lang.javascript... server side stuff when discussing ajax) Then, I'd evaluate the response text to get an ... JSON objects sent as a http request - comp.lang.java.help ... Display PDF from ... networking with a pc question - comp.unix.solariswhen i try pinging the sun from the pc, i get "request ... pc sends the four requests. snoop sees the request and response ... sigh. no errors. some collisions (expected ... ASPI: MODE SENSE locks computer up on a *specific* device - comp ...It works as expected on two drives (an IDE CD ... device gets these vendor-specific requests > from another program. Get a ... Besides that I'll try to get a response from Sony ... How to get Mail to ask for delivery reports/answer requests ...TIA Marc -- Switzerland/Europe <http://www ... Reply: Marc: 5/5/2006 1:37:41 PM ... get Mail to ask for delivery reports/answer requests ... How to get ... Port Used to Communicate Between Two HPUX Servers - comp.sys.hp ...Hi Rick, Thanks for the response. I made a ... work: [Thr 6] *** WARNING => Connection request ... trying to connect, the error message you get from telnet > is expected ... Unusual Query Help Request - comp.databases.mysqlIs a response > such as yours in any way better than the 'spam', 'trolling' etc so ... HTTP Request Query String Protection ... added a // "mac" parameter which will be a ... Unit attention and REQUEST SENSE - comp.periphs.scsiReply: BubbaGump: 2/17/2007 2:12:13 AM ... next SCSI command that is not a REQUEST SENSE or an INQUIRY ... these sorts of issues make sense to me as an expected ... how to enable PUT reqests for Apache 2 - comp.infosystems.www ...Reply: santoshjoseph73 (1) 2/16/2007 12:14:07 AM ... remote access on the ... on ... those created by standard web servers. ... HTTP requests ... new fstream isn't a weirdo, is it? - comp.lang.c++.moderated ...... false even though the file exists, etc.) as I expected. ... Contribute New Article Reply to this ... fstream is ... Image.GetInstance(url) is making a new HTTP request to get your ... server's address in ntp payload? - comp.protocols.time.ntp ...Remember that RFC 1123 is not addressing any particular request/response protocol. ... But my point is that UDP/IP was not expected to ... See http://www.cs.helsinki.fi/linux ... Request help as to why this OpenGL program fails - render to FBO ...Request help as to why this OpenGL program ... I have not been able to figure out why I get this error here. ... Reply: Logo for Single Page Interface (SPI) web applications - comp.lang ...... it clear that the back button does not work as expected within the website. Anyway, to get ... in the top banner of the website: http ... Reply: Request-Response Testing with F#... to use F# to perform HTTP request-response ... test case // get ViewState and EventValidation // send HTTP request and get response // check response for expected value ... Test Run: Request/Response Testing with Windows PowerShellThe script can then retrieve the HTTP response and examine it for an expected value to ... values # construct post data # send HTTP request, get response ... HTTP/1.1: Status Code Definitionspart of Hypertext Transfer Protocol ... in response to a request other than GET or HEAD, the user agent MUST NOT ... is expected to repeat this single request via ... jQuery.get() – jQuery API... from the server using a HTTP GET request. ... that is executed if the request succeeds. dataTypeThe type of data expected from ... would make the call, see a response, and not get ... Hypertext Transfer Protocol - Wikipedia, the free encyclopediaThe Hypertext Transfer Protocol (HTTP) is an application protocol for distributed ... identical to the one that would correspond to a GET request, but without the response body. List of HTTP status codes - Wikipedia, the free encyclopedia... is a list of Hypertext Transfer Protocol (HTTP) response status ... In a GET request, the response will contain ... and is not expected to be implemented by actual HTTP servers. HTTP Response Codes - IT Communities - Share Knowledge at Toolbox.com... is expected of the client. Regarding 304(Not Modified) Http Status code,In case the client has performed a conditional GET request and ... the 304 HTTP response must not ... 6/19/2012 8:09:05 PM
|