On Tue, 24 Sep 2002, Josh wrote: > The error message is as follows > In string, @63 now must be written as \@63 at -e line 1, near "#foo-bar > Target[789]: > 1.3.6.1.2.1.10.32.2.1.7.57.789&1.3.6.1.2.1.10.32.2.1.9.57.789:SNMPSTRING@IP" > Execution of -e aborted due to compilation errors. > > The code is as follows, but well, the @ is escaped so I've nfc, I've tried > double escaping it which did not work. Any help would be appreciated. even a > better way to accomplish the same thing. Im new to this so please exscuse my > unwieldy code.
The error is from the perl called from the system command. #!/usr/bin/perl -w use strict; my $str ='abc@def'; system ("/usr/bin/perl -p -i -e '\@def=(12,34,56);s/1234/$str/' somefile"); The main script generates the string with a literal '@' but the perl in the system command is not sure if it is a literal '@' or not. perldoc perldiag (search for '\@') Run the above script and check the output > #!/usr/bin/perl > ############################################################################ > # > #This program is part of a 3 file team that consists of: > # > #A web based form that takes information on a DSL Account using that info. > # > #An expect script that maps the person into our DSL router. > # > #This file that takes the same info and adds them to our MRTG Graphs. > # > ############################################################################ > # > > #Get The variables from the web and then split them into name value pairs. > #Then split THOSE pairs and assign them to a hash called "bar" > > @foo = split (/&/, $ENV{'QUERY_STRING'}); > foreach $i (@foo) > { > ($name, $value) = split(/=/,$i); > $bar{$name} = $value; > } > > #Prepare the information to be written to file. > $profile = "#$bar{cust_name}\n" . > "Target[$bar{dlci}]: > 1.3.6.1.2.1.10.32.2.1.7.57.$bar{dlci}&1.3.6.1.2.1.10.32.2.1.9.57.$bar{dlci}: > SNMPSTRING\@IP.OF.HOST\n" . > "MaxBytes[$bar{dlci}]: 192000\n" . > "AbsMax[$bar{dlci}]: 192000\n" . > "Title[$bar{dlci}]: $bar{title}\n" . > "PageTop[$bar{dlci}]: <h1>$bar{cust_name} (DLCI $bar{dlci})</h1>\n" . > "<table>\n" . > "<tr><td>Service:</td> <td>Level 3</td></tr>\n" . > "<tr><td>Bandwidth:</td> <td>$bar{rate_limit}/$bar{police}</td></tr>\n" . > "<tr><td>Binding:</td><td>bridged</td></tr>\n" . > "</table>\n\n"; > > #Check to see wether or not we are placing the new info into the Business Or > Consumer Section. > > system "perl -p -i -e 's!############ END DSL BUSINESS ACCOUNTS > #############!$profile\n############ END DSL BUSINESS ACCOUNTS > #############!gi' /usr/local/apache/htdocs/mrtg/fooness.cfg"; The above one-liner inside your script that is causing the problem Why don't you create a temporary file, write the modified output to it and copy it back when finished. open (FOONESS, '/usr/local/apache/htdocs/mrtg/fooness.cfg') or die "Error:$!\n"; open (TEMPFOO, '>/usr/local/apache/htdocs/mrtg/fooness.cfg.bak') or die "Error:$!\n"; while (<FOONESS>) { s/..../....../; print TEMPFOO; } close (FOONESS) close (TEMPFOO); rename (..../fooness.cfg.bak, ..../fooness.cfg); If you don't want to code all of that give this a try { local @ARGV = qw(/usr/local/apache/htdocs/mrtg/fooness.cfg); local $^I = ''; # Does the same as -i command line flag while (<>) { s/....../....../gi; print; } } > open(STUFF, "</usr/local/apache/htdocs/mrtg/fooness.cfg"); > print "Content-Type: text/html \n\n <HTML><HEAD></HEAD><BODY>"; > print "$profile"; > print <STUFF>; > print "</BODY></HTML>"; > close(STUFF); > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]