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: Intermediate:
Passing Arguments to perl script through HTML

 



karthikraju.n
Novice

Jan 1, 2014, 2:31 AM

Post #1 of 7 (1839 views)
Passing Arguments to perl script through HTML Can't Post

Hi,

How can we pass arguments from html program to perl script,

will You please send a simple, sample code.

This plays a crucial role in my project,

Thanks in advance,

Karthik


BillKSmith
Veteran

Jan 1, 2014, 5:36 AM

Post #2 of 7 (1832 views)
Re: [karthikraju.n] Passing Arguments to perl script through HTML [In reply to] Can't Post

Unfortunately there is no "simple" answer. The perl module CGI.pm is a huge help. You will probably find its documentation overwhelming. (Your question suggests that your are not already familiar with the CGI standard.)
I recommend the book "Official Guide to Programming with CGI.pm".
Good Luck,
Bill


karthikraju.n
Novice

Jan 1, 2014, 10:15 PM

Post #3 of 7 (1825 views)
Re: [BillKSmith] Passing Arguments to perl script through HTML [In reply to] Can't Post

Hi Bill,

Thanks a lot for responding for my Post,

I have basic idea in CGI,

I will try to explain my requirement,

We have a file in filer location(in this location there is no any server), and the content of the file looks like,

ABCDEF ABCDEF_123 MACHINE1
KLMNOP KLMNOP_1 MACHINE2

I need to add # symbol in this file in required line,

Through perl i am able to doing this ex:- >abc.pl KLMNOP

It is successfully updating the filer file

as
ABCDEF ABCDEF_123 MACHINE1
#KLMNOP KLMNOP_1 MACHINE1

And when i am trying to do this with CGi script, by passing parameters through dropdown list, it is not updating in filer location,

But it is updating in my local machine, where file resides in the same folder.

In filer there is no any server, Is this is the reason of not updating through CGI ???.

Think i explained my requirement clearly,

Please let me know if my explanation is not clear,

If required, i will send the code.

Thanks
karthik


FishMonger
Veteran / Moderator

Jan 2, 2014, 6:09 AM

Post #4 of 7 (1810 views)
Re: [karthikraju.n] Passing Arguments to perl script through HTML [In reply to] Can't Post

What methods do you have available to you to connect to the remote system?

In order to connect to the remote system it will need to be running some type of server process to allow you to connect and modify files, which by definition means that it's a server.

You will probably need to post your cgi script.


(This post was edited by FishMonger on Jan 2, 2014, 6:10 AM)


karthikraju.n
Novice

Jan 6, 2014, 2:51 AM

Post #5 of 7 (1752 views)
Re: [FishMonger] Passing Arguments to perl script through HTML [In reply to] Can't Post

Hi, here is my perl script, would you please help us by develop same script using CGI.

Code
use Tie::File; 

my $dir = "\\\\xxx\\xxxx\\xxxxxxxxxx\\xxxxx\\xxxxxx\\file.txt";

my $groupName = $ARGV[0]; # passing arguments as > progname.pl Karthik ON
my $switch = $ARGV[1];
my $on = "on";
my $off = "off";

chomp($groupName);
chomp($switch);

if($switch eq $on)
{
tie @array, 'Tie::File', $dir or die "can't read open '$fp': $OS_ERROR";
for (@array)
{
if($_ =~ /^$groupName /)
{
print "\n\n\t Already ON!!\n";
last;
}
else
{
s/#$groupName /$groupName /g;
}
}
print "\nDONE\n";
}
elsif($switch eq $off)
{
tie @array, 'Tie::File', $dir or die "can't read open '$fp': $OS_ERROR";
for (@array)
{
if($_ =~ /^#$groupName /)
{
print "\n\n\t Already OFF!!\n";
last;
}
else
{
s/$groupName /#$groupName /g;
}
}
print "\nDONE\n";
}
else
{
print "\n Warning: Incorrect Input";
}



(This post was edited by FishMonger on Jan 6, 2014, 8:45 AM)


BillKSmith
Veteran

Jan 6, 2014, 7:10 AM

Post #6 of 7 (1747 views)
Re: [karthikraju.n] Passing Arguments to perl script through HTML [In reply to] Can't Post

I have several issuses with the style of the code that you posted. I will assume that "it works" as you described.

Your next requirement is not clear. The meaning of "local" and "remote" depend on your viewpoint.

I assume that your data file and the code to edit it are on one computer. You wish to provide arguments, and execute that code from another computer.

There are several ways you might do this, but each requires (as FishMonger already stated) an appropriate server on the same machine as the data file. The CGI approch requires a "web server" (which you do not seem to have).
Good Luck,
Bill


FishMonger
Veteran / Moderator

Jan 6, 2014, 8:31 AM

Post #7 of 7 (1744 views)
Re: [karthikraju.n] Passing Arguments to perl script through HTML [In reply to] Can't Post

File::Remote - Read/write/edit remote files transparently
http://search.cpan.org/~nwiger/File-Remote-1.17/Remote.pm

 
 


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

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