Please be patient. I'm very new to perl. I'm passing a HTML variable from html form to a PERL/CGI script. Pls see the following
#!/usr/bin/perl
use strict; use warnings;
use CGI::Carp; # send errors to the browser, not to the logfile
use CGI;
my $cgi = CGI->new(); # create new CGI object
my $name = $cgi->param('servername');
print $cgi->header('text/html');
print "Server name is /n, $servername";
#system("/var/www/cgi-bin/localbashscript $servername");
#system("ssh $servername "remotebashscript" > localfile or display back to html );
Basically from the HTML form, I need to pass the server name. I tried using the system command to pass on the servername to "localbashscript" that runs my ssh command. But, I cannot get it to work. It was suggested that I do the SSH in PERL, but I have no idea how to do it.
In short, I have to call a bash script (remotebashscript) on the remote server ( $servername) and display the content back to the html or at least pipe it to a local file. The first thing I need to do before running the remotebashscript is to set my environment variables. This is how I would do it in bash. I set my env variable by sourcing the .profile and then I execute the remotebashscript and redirect it to a local file.
ssh $servername ". ~/.profile;remotebashscript" > localfile
I have no idea how to achieve the same thing using perl and seek your help. I tried below and did not work
system("ssh $servername ". ~/.profile; remotebashscript" ");
Thanking you in advance