help with variable
I have 10 scripts and they all have variable $phone_number=(XXX); I need to made module that will efect all scripts to use the value from that variable. How can I do that? Thanks Alen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Off-Topic (200%) - Where are you from?
-Original Message- From: walter [mailto:walter]On Behalf Of walter valenti Sent: Friday, November 09, 2001 8:07 AM To: Etienne Marcotte Cc: [EMAIL PROTECTED] Subject: Re: Off-Topic (200%) - Where are you from? Bosnia and Herzegovina Sarajevo Alen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Learn Perl
I found link with printed book : Teach Yourself Perl 5 in 21 days David Till http://www.vel-kladusa.net/Perl21/Perl21/index.htm
Re: need code
I only had problems with executing script from web. It's for sure that I will blok any char ,accept numbers letters and underline. My problem was ,that I coudn't force script to accept variable input and execute command (from web). now everything works fine,it was mestake in command syntax. Thanks Alen - Original Message - From: Curtis Poe [EMAIL PROTECTED] To: Camilo Gonzalez [EMAIL PROTECTED]; 'Alen Sarkinovic' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, June 20, 2001 9:40 PM Subject: RE: need code --- Camilo Gonzalez [EMAIL PROTECTED] wrote: try system (/bin/somecommand $variable); or even `somecommand $variable`; -Original Message- From: Alen Sarkinovic [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 20, 2001 2:11 PM To: [EMAIL PROTECTED] Subject: need code Hi Can anybody send me code of perl that will take input from web and execute Unix command ,I mean SYSTEM(/bin/somecommand $variable) I have try everything but still not able to execute from web ,everything goes fine from command line :perl -T script.pl variable=blabla Be very, very careful about this! It's extremely dangerous to run arbitrary commands with system(). If you already know the command you want to run, try using the multiple argument form of system (untested code): #/usr/bin/perl -wT use strict; use CGI qw/:standard/; my $program= '/bin/somecommand'; my $dirty_variable = param( 'variable' ); # untaint the variable # you'll need to create your own regex if \w+ does not # meet your needs my ( $variable ) = ( $dirty_variable =~ /^(\w+)$/ ); if ( ! $variable ) { some_error_routine( $variable ) } my $bad_status = system( $program, $variable ); if ( $bad_status ) { die $program returned a bad error code: $? } Using the multiple argument form of 'system' forces the arguments to be passed to the program and not to the shell, where they could be interpreted in unexpected (and possibly dangerous) ways. Absolutely do NOT use backticks unless it is critical that you capture the output of the command. Backticks are extremely dangerous if you are allowing any user data near the shell. Cheers, Curtis Poe = Senior Programmer Onsite! Technology (http://www.onsitetech.com/) Ovid on http://www.perlmonks.org/ __ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/
problem with command system,again
Hello , Again, problem with executing perl script from web . I have fixed all my code and did not get any mestake with option perl -T This perl script does not have any problem with executing from command line : perl -T smsgw.pl dest=5453 msgtxt=blabla but when I try to made submit from web I get foloving $retval =65280 ,is this some BUG or what? Here is script called smsgw.pl #!/usr/bin/perl -w #=== # Program : smsgw.pl # Author : Philippe Andersson # Date: 24/03/99 # Version : 1.1 # Comment : (c) Les Ateliers du Heron, 1999 for Scitex Europe, S.A. # Version History : # * 1.0 (15/03/99) - Initial release. # * 1.1 (24/03/99) - Fixed a problem with multi-line input. #=== #--- # Name the global variables my $dest = ; my $msgtxt = ; # Create en instance of CGI my $query = new CGI; # Send the MIME header print $query-header (text/html); # Grab posted values $dest = $query-param (dest); $msgtxt = $query-param (msgtxt); # Was at least one field filled-in ? if (($dest eq ) || ($msgtxt eq )) { print $query-start_html (-title = Greska !); print H1Greska !/H1\n; print PSvi podaci su obavezni!; print $query-end_html; exit; } # Check message length my $txtlen = length ($msgtxt); if ($txtlen 160) { print $query-start_html (-title = Error !); print H1Error !/H1\n; print PVasa poruka ne moze biti duza od 160 (char)karaktera (now$txtlen). $ print Ovaj 160 char limit je ugraden u SMS protocol i ne moze biti ; print prekoracen ! ; print $query-end_html; exit; } # Remove newlines from msgtxt (replace them by space) $msgtxt =~ s/\n/ /g; #=== print $query-start_html (-title = SMS Sending Rezultat); print H1SMS Sending Rezultat/H1\n; print Poruka koju ste poslali glasi : $msgtxt; #--- # Submit the sendsms request my $retval = 0; if (($dest =~ /^([-\@\w.]+)$/) ($msgtxt =~ /^([-\@\w.]+)$/)) { delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer $ENV{PATH} = '/bin:/usr/local/bin:/usr/bin/'; $retval = system (/bin/echo,$msgtxt,| /usr/bin/gnokii/gnokii,--sendsms, $dest$ } if ($retval == 0) { print POK!!!/P\n; } else { print PError./P\n; print $retval; } # End the HTML #--- exit; use strict; use diagnostics; use CGI;
need code
Hi Can anybody send me code of perl that will take input from web and execute Unix command ,I mean SYSTEM(/bin/somecommand $variable) I have try everything but still not able to execute from web ,everything goes fine from command line :perl -T script.pl variable=blabla
problem with command SYSTEM
Helo , I have problem with submiting form to perl script : What realy problem is when I try to submit form trought web I get $retval= -1 from smsgw.pl script, but when I try that from command line : perl smsgw.pl dest=233435 msgtxt=hi it works without any problem . Where I'm wrong? Thanks , Alen Here is perl script called smsgw.pl #!/usr/bin/perl -w use strict; use diagnostics; use CGI; #--- # Name the global variables my $dest = ; my $msgtxt = ; # Create en instance of CGI my $query = new CGI; # Send the MIME header print $query-header (text/html); # Grab posted values $dest = $query-param (dest); $msgtxt = $query-param (msgtxt); # Was at least one field filled-in ? if (($dest eq ) || ($msgtxt eq )) { print $query-start_html (-title = Greska !); print H1Greska !/H1\n; print PSvi podaci su obavezni!; print $query-end_html; exit; } # Check message length my $txtlen = length ($msgtxt); if ($txtlen 160) { print $query-start_html (-title = Error !); print H1Error !/H1\n; print PVasa poruka ne moze biti duza od 160 (char)karaktera (now$txtlen). ; print Ovaj 160 char limit je ugraden u SMS protocol i ne moze biti ; print prekoracen ! ; print $query-end_html; exit; } # Remove newlines from msgtxt (replace them by space) $msgtxt =~ s/\n/ /g; #=== print $query-start_html (-title = SMS Sending Rezultat); print H1SMS Sending Rezultat/H1\n; print bla bla bla : $msgtxt; #--- # Submit the sendsms request my $retval = 0; $retval = system (echo $msgtxt | /usr/bin/gnokii/gnokii --sendsms $dest); if ($retval == 0) { print PPoruka je uspjesno isporucena!!!/P\n; } else { print PPoruka nije isporucena ! Pokusajte ponovo./P\n; print $retval; } # End the HTML #--- exit;