Re: Example Input Datas

[email protected] (Rodrigo Tavares)
Newsgroups perl.beginners.cgi
Message-ID <[email protected]>
Hello Jeff,

Other error has come:

syntax error at
home/faria/public_html/cgi-bin/perl/entrada-dados.cgi
line 19, near "print"
Execution of
/home/faria/public_html/cgi-bin/perl/entrada-dados.cgi
aborted due to compilation errors.

My all code is a below.

#!/usr/bin/perl -wt

use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;

print header;
print start_html("Modify Information");

open FILE,"/opt/croc/postgresql.conf" or die $!;
my @file = <FILE>;
close FILE;

open FILE,">","/opt/croc/postgresql.conf" or die $!;
for (@file)
  {
     #system("perl -pi -e 's/192.168.1.1/10.0.0.1/g'
/opt/croc/postgresql.conf"); s/192.168.1.85/10.0.0.1/g
     print FILE $_;
  }
close FILE;
print end_html;

Thanks,

Rodrigo Faria





--- Jeff Pang <[email protected]> escreveu:

> print FILE,$_;
> 
> Here comma is not needed.
> change to:
> 
> print FILE $_;
> 
> Also I'd suggest you always add the "use strict" at
> the begin of your cgi scripts.
> 
> -----Original Message-----
> >From: Rodrigo Tavares <[email protected]>
> >Sent: Mar 8, 2007 8:04 PM
> >To: [email protected]
> >Subject: Re: Example Input Datas
> >
> >Hello Jeff,
> >
> >Well, thanks your help. 
> >More one thing.
> >When I try to run the cgi in browser come this
> message
> > 
> >
> >Software error:
> >
> >No comma allowed after filehandle at
>
>/home/faria/public_html/cgi-bin/perl/entrada-dados.cgi
> >line 19.
> >
> >See my below code.
> >
> >print header;
> >print start_html("Modify Information");
> >open FILE,"/opt/croc/postgresql.conf" or die $!;
> >my @file = <FILE>;
> >close FILE;
> >
> >open FILE,">","/opt/croc/postgresql.conf" or die
> $!;
> >for (@file)
> >  {
> >     #system("perl -pi -e
> 's/192.168.1.1/10.0.0.1/g'
> >/opt/crocodilo/postgresql.conf");
> >     s/192.168.1.85/10.0.0.1/g
> >     print FILE,$_;
> >  }
> >close FILE;
> >print end_html;
> >
> >What's wrong ?
> >
> >Best regards,
> >
> >Rodrigo Faria
> >
> >>
> >>>I'm beginner in Perl with CGI.
> >>>I create a two input box;
> >>>
> >>>In the first input box, I'll put the ip adress.
> >>>In the second input box I'll put the port
> >>>
> >>>Then when i click em submit, the cgi must make:
> >>>
> >>>perl -pi -e 's/192.168.1.1/10.0.0.1/g'
> /opt/myfile
> >>>
> >>>How I can to do it ?
> >>>
> >>
> >> At first you need to ensure that your cgi script
> has
> >the privileges to
> >> write/modify the file "/opt/myfile".
> >> Then you may call:
> >> system "perl -pi -e ..."
> >> to do the things you wanted in the cgi script.
> >>
> >> But I think the good way is something like:
> >>
> >> # copy the old content in that file to an array
> >> open FILE,"/opt/myfile" or die $!;
> >> my @file = <FILE>;
> >> close FILE;
> >>
> >> # re-write the new content to the file
> >> open FILE,">","/opt/myfile" or die $!;
> >> for (@file) {
> >>    s/192.168.1.1/10.0.0.1/g;
> >>    print FILE,$_;
> >> }
> >> close FILE;
> >>
> >>
> >> Is it?
> >> Hope this helps.
> >
> >__________________________________________________
> >Fale com seus amigos  de graça com o novo Yahoo!
> Messenger 
> >http://br.messenger.yahoo.com/ 
> >
> >-- 
> >To unsubscribe, e-mail:
> [email protected]
> >For additional commands, e-mail:
> [email protected]
> >http://learn.perl.org/
> >
> >
> 
> 
> --
> To unsubscribe, e-mail:
> [email protected]
> For additional commands, e-mail:
> [email protected]
> http://learn.perl.org/
> 
> 
> 


__________________________________________________
Fale com seus amigos  de graça com o novo Yahoo! Messenger 
http://br.messenger.yahoo.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.