Solved

Calling lynx from a perl script...

Posted on 1997-12-22
3
568 Views
Last Modified: 2012-06-27
I am trying to call the text browser lynx from inside a perl script using the -source option in order to grab the output (HTML code) and append it to a file... however, it just will not work when I call it from the web... it only works if I call it directly from the command line (if I have a one-line  script with almost exactly the same line.  I've tried changing permissions on the script, etc. to rwx by world and several variations of the call, but no to no avail.  Ideally, this will take a URL from a form via POST and then go grab the source code and keep it in a file.  Any ideas how I can implement this?  There must be a way without using sockets since a similar script works with an exact call when executed from the command line.  (Also, I'm using HP-UX).

The line is:

system "lynx $link -source >> megafile.spd\n";

where "$link" is a URL received from the POST method.


Thanks... Ryan
0
Comment
Question by:laze
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
alamo earned 100 total points
ID: 1209390
The first thing to check is that you are actually executing lynx - try checking whether system returns an error, and maybe the error will tell you something.

Also, it's possible that you need the full pathname for megafile.spd, what directory is current varies server to server.

Also- if taint checking is enabled on your system that might be the problem (I think that's the name for it, not certain). That system command using $link derived from a form is actually a dangerous practice unless you process it specially, since $link could be set by someone malicious to something like "|rm * |". There are ways around this, most easily by using the vector form  of system, but that doesn't allow for redirection or piping (which is why it's safe).

I had a similar problem, and decided to solve it by calling a shell script. (This was an easy decision since I had to run the script in question on both a Unix and a NT server, so this approach helped me more easily isolate the differences in calling lynx between the two systems.) You would use a system call similar to:

system("/home/mydir/calllynx.sh",$link) && die("system failed: $!");

and calllynx.sh would be:

/usr/local/bin/lynx -source  $1 >>/home/mydir/megafile.spd

One of the above approaches should solve your problem, good luck!
0
 

Author Comment

by:laze
ID: 1209391
Thank you, alamo... the second suggestion worked.  Thanks a bunch!  (threw in a few extra points for you)
0
 
LVL 6

Expert Comment

by:alamo
ID: 1209392
Thanks, and Happy Holidays!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Reading fields from the text file. 4 101
Perl script to parse xml file 2 125
crawling gofundme 4 132
Executing multiple sybase statements in perl dbi 2 94
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

860 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