CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: DBI:
perl mysql cgi

 



big_v
New User

Sep 13, 2002, 1:20 AM

Post #1 of 3 (4702 views)
perl mysql cgi Can't Post

I have a perl cgi script that when called will access a remote mysql database through an ssh tunnel (don't be alarmed!!). When I access the script with Netscape, the web server does not return the values form the mysql select. It's as if the web server timed out before mysql returns, and If I run it from the shell it works perfectly!!

The problem isn't with mysql, as the example below should list the files in my home directory on the remote machine!! Again, this works from the shell!!


Code
#!/usr/bin/perl -w 
use DBI;
use strict;

print"Content-type:text/html\n\n";

print_head();

foreach $_ (`ssh <ip address> ls -l`)
{
(my $1,my $2,my $3) = /(\S+)\s+(\S+)\s+(.*)/;
print "$1 $2 $3<br>\n";
}
print "<br><br>system call done\n";

print_tail();

sub print_head
{
print"<title>Title</title>";
print"<h2>output</h2>";
}

sub print_tail
{
print"</body>\n";
print"</html>\n";
}

All I get is a message saying 'system call done' (see code) and nothing else.

Any ideas please!!?


lackluster
New User

Sep 19, 2002, 1:09 PM

Post #2 of 3 (4622 views)
Re: [big_v] perl mysql cgi [In reply to] Can't Post

Perhaps you should print out the ssh line. You may have gotten "Access is denied. " (or similar) when run in cgi context.


big_v
New User

Sep 20, 2002, 2:19 AM

Post #3 of 3 (4617 views)
Re: [lackluster] perl mysql cgi [In reply to] Can't Post

I've sussed it now - ssh require a tty and thus cannot be run from a cgi script directly

thanks
Smile

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives