Solved

Calling lynx from a perl script...

Posted on 1997-12-22
3
558 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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks, and Happy Holidays!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 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

11 Experts available now in Live!

Get 1:1 Help Now