[19709] in Perl-Users-Digest
Perl-Users Digest, Issue: 1904 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 10 14:05:59 2001
Date: Wed, 10 Oct 2001 11:05:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1002737113-v10-i1904@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 10 Oct 2001 Volume: 10 Number: 1904
Today's topics:
Re: [Newbie] length of a multidim.-array (Damian James)
Re: [Newbie] length of a multidim.-array <nurdogan@uni.de>
Re: Can I do these with the debugger? (Mark Jason Dominus)
chdir() not working ? <john@trumpetweb.co.uk>
Re: chdir() not working ? (Rafael Garcia-Suarez)
Re: chdir() not working ? <jurgenex@hotmail.com>
Re: Checking Network Access <bart.lateur@skynet.be>
Re: Checking Network Access <MrsKensingtonUK@yahoo.co.uk>
Re: Checking Network Access nobull@mail.com
Re: current dir. <Doug.King@abh.siemens.com>
DBI ODBCD MS-Access Error (Scott Davis)
Re: DBI ODBCD MS-Access Error (John J. Trammell)
executing batch file from script <jessica.bull@broadwing.com>
Hashes as class members <ecifreo@austin.rr.com>
Re: Hashes as class members <JPFauvelle@Colt-Telecom.fr>
how to execute a unix program with a cgi script <johan@basberg.comNOSPAM>
Re: how to execute a unix program with a cgi script <Thomas@Baetzler.de>
Re: how to execute a unix program with a cgi script <jessica.bull@broadwing.com>
Re: how to execute a unix program with a cgi script <bart.lateur@skynet.be>
Re: how to execute a unix program with a cgi script news@roaima.demon.co.uk
Re: how to execute a unix program with a cgi script <johan@basberg.comNOSPAM>
Keeping an escape code in a line (Greg Thorne)
Re: Keeping an escape code in a line blah@blah.blah.invalid
Re: Keeping an escape code in a line <Jean-Philippe.AVELANGE@cgey.com>
Re: Keeping an escape code in a line nobull@mail.com
Re: Need help - pragmatic modules not available <mjcarman@home.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 10 Oct 2001 13:05:28 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: [Newbie] length of a multidim.-array
Message-Id: <slrn9s8hn4.she.damian@puma.qimr.edu.au>
On 10 Oct 2001 05:50:20 -0700, nurdogan erdem said:
>hi,
>
>i have a array with includes 2 arrays. Like this:
>...
>How can i find out i.e, the length of the first array?
>
>$length=@menus[0]; does not work :-(
>
$length = @{$menus[0]};
See `perldoc perllol`.
Cheers,
Damian
--
@:=grep!(m!$/|#!..$|),split//,<DATA>;@;=0..$#:;while($:=@;){$;=rand
$:--,@;[$;,$:]=@;[$:,$;]while$:;push@|,shift@;if$;[0]==@|;select$,,
$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/} __END__
Just another Perl Hacker,### http://home.pacific.net.au/~djames.hub
------------------------------
Date: Wed, 10 Oct 2001 18:37:43 +0200
From: "Nurdogan Erdem" <nurdogan@uni.de>
Subject: Re: [Newbie] length of a multidim.-array
Message-Id: <9q1tgp$nev$02$1@news.t-online.com>
thx all!
nurdogan
------------------------------
Date: Wed, 10 Oct 2001 17:13:08 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Can I do these with the debugger?
Message-Id: <3bc481a3.56a8$1d@news.op.net>
In article <3BC44705.75F3BC5C@monmouth.com>,
Richard Trahan <rtrahan@monmouth.com> wrote:
>(1) b FILENAME LINE
I think there's a way to do this, but I don't remember what it is. If
it comes back to me, I'll post again.
>(3) setting up an init file that will execute debugger commands
>(like setting breakpoints) at startup.
The documentation for this was accidentally moved to 'perldebguts' in
some recent version of Perl. Look for information about '.perldb' files:
At the start, the debugger reads your rc file (./.perldb
or ~/.perldb under Unix), which can set important options.
This file may define a subroutine "&afterinit" to be exe-
cuted after the debugger is initialized.
(etc.)
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Wed, 10 Oct 2001 14:57:33 GMT
From: "John P" <john@trumpetweb.co.uk>
Subject: chdir() not working ?
Message-Id: <xlZw7.10914$hJ6.695554@news1.cableinet.net>
Hi there All,
I'm sure there's a simple answer but I'm being driven mad here.
Why doesn't chdir ever seem to work even when -d tells me that the dir
exists ??
use Cwd; $cwd=cwd;
my $newdir = $cwd."/newdir";
if (-d $newdir) # if exists
{chdir($newdir);} # change dir
else # doesnt exist
{mkdir($newdir); # create it
chdir($newdir);} # move to new dir
Thanks in advance.
------------------------------
Date: 10 Oct 2001 15:06:20 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: chdir() not working ?
Message-Id: <slrn9s8ov0.il2.rgarciasuarez@rafael.kazibao.net>
John P wrote in comp.lang.perl.misc:
} Hi there All,
}
} I'm sure there's a simple answer but I'm being driven mad here.
} Why doesn't chdir ever seem to work even when -d tells me that the dir
} exists ??
}
} use Cwd; $cwd=cwd;
} my $newdir = $cwd."/newdir";
}
} if (-d $newdir) # if exists
} {chdir($newdir);} # change dir
}
} else # doesnt exist
} {mkdir($newdir); # create it
} chdir($newdir);} # move to new dir
Tell perl to give you a hint :
chdir $newdir or die "Can't chdir to $newdir : $!\n";
Same remark for mkdir.
--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
This theory has become known as the waste of time theory and was
abandoned in 1956. -- Monty Python, Penguins
------------------------------
Date: Wed, 10 Oct 2001 09:01:37 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: chdir() not working ?
Message-Id: <3bc470e2@news.microsoft.com>
"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
news:3bc46848@news.microsoft.com...
> "John P" <john@trumpetweb.co.uk> wrote in message
> news:xlZw7.10914$hJ6.695554@news1.cableinet.net...
> > I'm sure there's a simple answer but I'm being driven mad here.
> > Why doesn't chdir ever seem to work even when -d tells me that the dir
> > exists ??
> >
> > use Cwd; $cwd=cwd;
> > my $newdir = $cwd."/newdir";
> >
> > if (-d $newdir) # if exists
> > {chdir($newdir);} # change dir
>
> Check the value of $newdir, it is "/newdir".
Sorry, please ignore.
I misread your code
jue
------------------------------
Date: Wed, 10 Oct 2001 13:50:04 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Checking Network Access
Message-Id: <odk8stcnes6tne8d7aaofhhuvch1vvbbn7@4ax.com>
MrsKensingtonUK wrote:
> if (copy($file, "c:\emptyFile"))
"\e" is the escape character.
If such a file path string is for use by perl only, you can just as well
use forward slashes.
--
Bart.
------------------------------
Date: Wed, 10 Oct 2001 14:53:41 +0100
From: "MrsKensingtonUK" <MrsKensingtonUK@yahoo.co.uk>
Subject: Re: Checking Network Access
Message-Id: <1002722721.15611.0.nnrp-07.3e31b93c@news.demon.co.uk>
I apologise i did not understand what you meant. I had never heard of the $!
variable (and if you look at it in that context it looks like masked
swearing, though i don't know any 2 letter swear words) but will store it
away for future use!
Yes it is the File::Copy function.
I've done some more testing and i can get it to work if i'm copying files
around my computer, its when i do it over the network it fails.
I had a look at the $! variable and it says "Access is denied", there is no
password on the share, and permissions (its win2K) for the share are
everyone = "Full Control" and the same for guest.
Any other ideas why i would be getting Access is Denied??
also what is this jeopardy thing. I do not understand!
Anyway thanks for your help and i apolagise for previous booboo's (grovel
grovel)!
Mrs K
<nobull@mail.com> wrote so wisely in message
news:u9k7y3lugy.fsf@wcl-l.bham.ac.uk...
> "MrsKensingtonUK" <MrsKensingtonUK@yahoo.co.uk> writes rudely in
> untrimmed jeopardy style[1] and without enough of a Usenet sense of
> humor:
>
> > <nobull@mail.com> wrote in message
news:u9vgholoav.fsf@wcl-l.bham.ac.uk...
> > > "MrsKensingtonUK" <MrsKensingtonUK@yahoo.co.uk> writes:
> > >
> > > > if (copy($file, "c:\emptyFile"))
> > > >
> > > > for some reason it always returns 0!
> > >
> > > What $! reason?
> >
> > Surely if i new the reason I wouldn't be asking what I was doing
> > wrong,
>
> I think you missed my point. When I say "What $! reason?" I meant
> "What is the proximate reason for failure that can be found in the $!
> variable?". More detail may also be found in the $^E variable.
>
> [1] Persistant jeopardy-quoting will get you killfiled by many of the
> most knowledgible people here. That does not include me[2]
> because I'm not a plonker[3] (yet).
>
> [2] I hope I do count as knowledgible but that's not really for me to
> judge.
>
> [3] At least not in the sense of one who "*plonk!*"s :-).
>
> --
> \\ ( )
> . _\\__[oo
> .__/ \\ /\@
> . l___\\
> # ll l\\
> ###LL LL\\
------------------------------
Date: 10 Oct 2001 18:01:27 +0100
From: nobull@mail.com
Subject: Re: Checking Network Access
Message-Id: <u9669nl994.fsf@wcl-l.bham.ac.uk>
"MrsKensingtonUK" <MrsKensingtonUK@yahoo.co.uk> writes:
> I had a look at the $! variable and it says "Access is denied", there is no
> password on the share, and permissions (its win2K) for the share are
> everyone = "Full Control" and the same for guest.
>
> Any other ideas why i would be getting Access is Denied??
This now has nothing to do with Perl - if access is denied this is
independant of the language you happen to use.
Are you perhaps running the script as "LocalSystem"?
Try a web search on the phrase "null session share".
> also what is this jeopardy thing. I do not understand!
Jeopardy is an American quiz show (sometimes seen here in the UK t0o)
in which the quizmaster gives "answers" and the contestants are
required to infer the questions.
The term jeopardy-posting or jeopardy-quoting is used to refer to the
practice of posting to Usenet with your response placed before the
quoted material.
Jeopardy-quoting is considered bad manners. Good manners on Usenet
requires that one quotes just enough of the message to which one is
responding to put one's responses in context and then puts the
response _after_ the quote - as I am doing here.
This of course has nothing whatever to do with Perl - the same
netiquette applies throughout Usenet but jeopardy-quoting and other
poor manners are less tolerated in "serious" newsgroups such as
comp.lang.*
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 10 Oct 2001 13:26:28 -0400
From: Doug King <Doug.King@abh.siemens.com>
Subject: Re: current dir.
Message-Id: <3BC484C4.521B55F5@abh.siemens.com>
Stephane TOUGARD wrote:
>
> In article <3BB08955.81D08C63@metadyne.uk.com>, Jeffrey Porter wrote:
> > This is a multi-part message in MIME format.
> > --------------5DC71650AE9537D21B5F9108
> > Content-Type: text/plain; charset=us-ascii
> > Content-Transfer-Encoding: 7bit
> >
> >
> >
> > I'm trying to write a perl program to go through each directory and list
> > the files in it & the path to that file.
> >
> > I've managed to write the code to list/change directories & list the
> > files in them.
> >
> > What I can't work out is how to get the full path of the current
> > directory I am in.
>
> use Cwd;
>
> my $current_dir = getcwd();
>
> Stephane
>
> >
Check out the File::Find module -- it will do most of the work of your
program for you!
------------------------------
Date: 10 Oct 2001 10:27:38 -0700
From: scott_k_davis@yahoo.com (Scott Davis)
Subject: DBI ODBCD MS-Access Error
Message-Id: <c3075022.0110100927.2319631b@posting.google.com>
I am trying to insert records into a MS-Access Database (Access 97 or
2000). I have downloaded all the latest perl modules and am able to
connect to the database, however when I try to insert records I get
the following error :
DBD::ODBC::st execute failed: [Microsoft][ODBC Microsoft Access
Driver] Too few parameters. Expected 2. (SQL-07001)(DBD:
st_execute/SQLExecute err=-1) at D:\DBD-ODBC-0
------------------------------
Date: Wed, 10 Oct 2001 12:40:21 -0500
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: DBI ODBCD MS-Access Error
Message-Id: <slrn9s9205.3hl.trammell@haqq.hypersloth.net>
On 10 Oct 2001 10:27:38 -0700, Scott Davis <scott_k_davis@yahoo.com> wrote:
> I am trying to insert records into a MS-Access Database (Access 97 or
> 2000). I have downloaded all the latest perl modules and am able to
> connect to the database, however when I try to insert records I get
> the following error :
>
> DBD::ODBC::st execute failed: [Microsoft][ODBC Microsoft Access
> Driver] Too few parameters. Expected 2. (SQL-07001)(DBD:
> st_execute/SQLExecute err=-1) at D:\DBD-ODBC-0
I'm going to go out on a limb here and guess that you're passing
zero or 1 arguments to your statement execute, when you should be
passing exactly two.
But I can't know that, since you didn't post any code.
--
After Spamtember comes Proctober.
------------------------------
Date: Wed, 10 Oct 2001 16:20:35 GMT
From: "Jessica Bull" <jessica.bull@broadwing.com>
Subject: executing batch file from script
Message-Id: <nz_w7.883395$ai2.67962521@bin2.nnrp.aus1.giganews.com>
I am on windows NT. I am trying to call a batch file to run from the
script. I am not able to get the script to call it correctly. I am getting
the error: Directory or Filename does not exist or is not an operable batch
program. Can someone help me out? This is what I have.
my $batchdir = "c:\\cdsdk";
my $rsobatch = "$batchdir\\rsogtecc.bat";
Code edited reads in all files in a directory.
elsif ($file =~ m/.*?\.RSO/i) {
$errormessage = Cpy_snd_chk($rso, $rsobatch);
push (@errors, $errormessage);
next;
}#end elsif
The code above calls a subroutine (edited below)...this is where I am trying
to call the batch file. The correct value is being passed in, but the OS
doesn't seem to like the command. Can someone help me out? Thanks so
much!!!
sub Cpy_snd_chk {
my ($path, $batch) = @_;
`$batch` or die "Batch file open failed: $batch : $! \n";
}
------------------------------
Date: Wed, 10 Oct 2001 11:36:12 -0500
From: "Eric Cifreo" <ecifreo@austin.rr.com>
Subject: Hashes as class members
Message-Id: <3bc47861$0$13457$39cecf19@nnrp1.twtelecom.net>
Greetings all,
I'm a Perl beginner, so I hope this isn't a FAQ. I've searched long and
hard for some examples of this, but I'm having trouble returning a hash from
a class.
Code follows below. When calling this object in an external script, addUser
works and getUser works. I can print out user info from inserted and
retrieved objects. User is another simple custom object I've written. Much
like a bean. (Ok, I confess I am primarily a Java programmer. *ducks*. I
wanted to see what Perl was all about....)
My problem is this: when I try to get the hash out of the Office object,
it's mangled somehow. If in the external script, I say:
my %userHash = $office->users();
foreach ($key (keys %userHash)) { # where the keys are the User's names
print("Key is $key.\n");
}
I get 'Key is : HASH(0x1d49fd8).'
Why are my keys hashes, when they were scalar strings upon creation? Why do
I only have one key, when I have eight User objects in the hash?
Is this making sense?
#############################
package Office;
use 5.006;
use strict;
use warnings;
use User;
sub new {
my ($type) = @_;
my $self = { };
$self->{users} = { };
bless $self, $type;
return $self;
}
sub addUser {
my $self = shift;
my $key = shift;
my $value = shift;
$self->{users}->{$key} = $value;
}
sub getUser {
my ($self,$key) = @_;
return $self->{users}->{$key};
}
sub users {
my $self = shift;
return $self->{users};
}
##############################
Thanks in advance,
Eric Cifreo
Austin, TX
------------------------------
Date: Wed, 10 Oct 2001 19:13:23 +0200
From: Jean-Philippe Fauvelle <JPFauvelle@Colt-Telecom.fr>
Subject: Re: Hashes as class members
Message-Id: <9nv8st8s4e5tt2a39tss5u99nfjk6lp905@4ax.com>
Le Wed, 10 Oct 2001 11:36:12 -0500, "Eric Cifreo" <ecifreo@austin.rr.com> écrit:
Your constructor returns an object reference, which is a scalar ($xxxx).
my $userHash = $office->users(); # $userHash instead of %userHash
while ( ($k,$v) = each(%$userHash) ) {
print("$k => $v\n");
}
use 5.006;
use strict;
use warnings;
use User;
sub new{
my($self) = @_;
my $class = ref($self) || $self;
return bless { 'users' => {} }, $class;
}
# sub addUser { shift->{'users'}->{shift} = shift;}
sub addUser {
my($self,$key,$value) = @_;
$self->{'users'}->{$key} = $value;
}
#sub getUser { return shift->{'users'}->{shift}; }
sub getUser {
my($self,$key) = @_;
return $self->{'users'}->{$key};
}
# sub users { return shift->{'users'} }
sub users {
my $self = shift;
return $self->{'users'};
}
Hope that helps.
Jean-Philippe Fauvelle
>Greetings all,
>
>I'm a Perl beginner, so I hope this isn't a FAQ. I've searched long and
>hard for some examples of this, but I'm having trouble returning a hash from
>a class.
>Code follows below. When calling this object in an external script, addUser
>works and getUser works. I can print out user info from inserted and
>retrieved objects. User is another simple custom object I've written. Much
>like a bean. (Ok, I confess I am primarily a Java programmer. *ducks*. I
>wanted to see what Perl was all about....)
>
>My problem is this: when I try to get the hash out of the Office object,
>it's mangled somehow. If in the external script, I say:
>
>my %userHash = $office->users();
>foreach ($key (keys %userHash)) { # where the keys are the User's names
> print("Key is $key.\n");
>}
>
>I get 'Key is : HASH(0x1d49fd8).'
>Why are my keys hashes, when they were scalar strings upon creation? Why do
>I only have one key, when I have eight User objects in the hash?
>Is this making sense?
>
>#############################
>package Office;
>
>use 5.006;
>use strict;
>use warnings;
>use User;
>
>sub new {
> my ($type) = @_;
> my $self = { };
> $self->{users} = { };
> bless $self, $type;
> return $self;
>}
>
>sub addUser {
> my $self = shift;
> my $key = shift;
> my $value = shift;
> $self->{users}->{$key} = $value;
>}
>
>sub getUser {
> my ($self,$key) = @_;
> return $self->{users}->{$key};
>}
>
>sub users {
> my $self = shift;
> return $self->{users};
>}
>##############################
>
>Thanks in advance,
>
>Eric Cifreo
>Austin, TX
>
------------------------------
Date: Wed, 10 Oct 2001 15:48:46 +0200
From: "JHWB" <johan@basberg.comNOSPAM>
Subject: how to execute a unix program with a cgi script
Message-Id: <9q1jm4$5lj$1@maud.ifi.uio.no>
I am trying to rename (using mv, move or rename) a file into something
different; nothing happens. Below is the code and the output from the
browser.
hehe - and yes, I am a perl newbie - so thanks for any replies! :-)
JHWB
cgi source
------------------------
($filename, $extension) = split(/\.(jpg|gif)$/,$borrowedMovie);
$cmd = "mv $borrowedMovie
$filename:@allParams[3]:$dateFormat:ute.$extension";
print "<p>command<br>$cmd<p>";
$failure = system($cmd);
print "<p>failure: $failure<p>";
------------------------
output
------------------------
failure: 512
------------------------
------------------------------
Date: Wed, 10 Oct 2001 16:28:20 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: how to execute a unix program with a cgi script
Message-Id: <k0m8st8tet955adiqo2rqvg4h9gku82013@4ax.com>
On Wed, 10 Oct 2001, "JHWB" <johan@basberg.com> wrote:
>I am trying to rename (using mv, move or rename) a file into something
>different; nothing happens. Below is the code and the output from the
>browser.
>cgi source
comp.infosystems.www.authoring.cgi would probably be a better choice to
ask about stuff like this.
> ($filename, $extension) = split(/\.(jpg|gif)$/,$borrowedMovie);
This looks weird. Use:
if(($filename, $extension) = ( $borrowedMovie =~ m/(.*)\.(jpg|gif)/i )){
instead and add some error handling code in an } else { branch below.
> $cmd = "mv $borrowedMovie
>$filename:@allParams[3]:$dateFormat:ute.$extension";
"@allParams[3] better written as $allParams[3]" :-)
> $failure = system($cmd);
> print "<p>failure: $failure<p>";
No. See perldoc -f system.
Are you sure you have the necessary permissions to access the file?
Are you sure that mv can be found in the current PATH while your cgi is
running?
HTH,
--
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl
------------------------------
Date: Wed, 10 Oct 2001 14:37:51 GMT
From: "Jessica Bull" <jessica.bull@broadwing.com>
Subject: Re: how to execute a unix program with a cgi script
Message-Id: <33Zw7.440251$Lw3.27467977@news2.aus1.giganews.com>
I don't see where you are actually calling the command? in any case, check
the module FILE:COPY on CPAN. it is an easy to use module and is cross
platform. much more stable than going out to the system to execute a
command. here some sample code (you will have to install the module though.
there is help in the faq to do this)
use File::Copy;
copy($oldfile, $newfile) or die "Copy failed: $! \n";
move ($oldfile, $archivedir) or die "Could not move files to archive: $!
\n";
"JHWB" <johan@basberg.comNOSPAM> wrote in message
news:9q1jm4$5lj$1@maud.ifi.uio.no...
> I am trying to rename (using mv, move or rename) a file into something
> different; nothing happens. Below is the code and the output from the
> browser.
>
> hehe - and yes, I am a perl newbie - so thanks for any replies! :-)
>
> JHWB
>
>
> cgi source
> ------------------------
> ($filename, $extension) = split(/\.(jpg|gif)$/,$borrowedMovie);
> $cmd = "mv $borrowedMovie
> $filename:@allParams[3]:$dateFormat:ute.$extension";
> print "<p>command<br>$cmd<p>";
> $failure = system($cmd);
> print "<p>failure: $failure<p>";
> ------------------------
>
>
> output
> ------------------------
> failure: 512
> ------------------------
>
>
>
------------------------------
Date: Wed, 10 Oct 2001 15:24:19 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: how to execute a unix program with a cgi script
Message-Id: <1hp8stgi8k644qf2j0cdft2b3rm538u0ig@4ax.com>
JHWB wrote:
>I am trying to rename (using mv, move or rename) a file into something
>different; nothing happens. Below is the code and the output from the
>browser.
>cgi source
>------------------------
> ($filename, $extension) = split(/\.(jpg|gif)$/,$borrowedMovie);
> $cmd = "mv $borrowedMovie
>$filename:@allParams[3]:$dateFormat:ute.$extension";
You're using '@' where you want to reference a scalar. Use '$' instead.
> print "<p>command<br>$cmd<p>";
> $failure = system($cmd);
> print "<p>failure: $failure<p>";
>------------------------
>output
>------------------------
>failure: 512
>------------------------
I think that's actually error number 2, whatever that may be... I'm not
sure, but assigning 2 to $! and then printing it out might give you the
equivalent error message in English.
Anyway, you needn't call an external program to do that. There's the
perl built-in rename() and the Module File::Copy at your disposal.
--
Bart.
------------------------------
Date: 10 Oct 2001 17:18:20 GMT
From: news@roaima.demon.co.uk
Subject: Re: how to execute a unix program with a cgi script
Message-Id: <3bc474cb@news.netserv.net>
JHWB <johan@basberg.comnospam> wrote:
> I am trying to rename (using mv, move or rename) a file into something
> different; nothing happens. Below is the code and the output from the
> browser.
> ($filename, $extension) = split(/\.(jpg|gif)$/,$borrowedMovie);
> $cmd = "mv $borrowedMovie
> $filename:@allParams[3]:$dateFormat:ute.$extension";
> print "<p>command<br>$cmd<p>";
> $failure = system($cmd);
> print "<p>failure: $failure<p>";
> ------------------------
I do hope that $borrowedMovie, $allParams[3], and $dateFormat aren't
obtained directly from a web form.
Chris
------------------------------
Date: Wed, 10 Oct 2001 19:24:05 +0200
From: "JHWB" <johan@basberg.comNOSPAM>
Subject: Re: how to execute a unix program with a cgi script
Message-Id: <9q20a5$6dg$1@maud.ifi.uio.no>
> > ($filename, $extension) = split(/\.(jpg|gif)$/,$borrowedMovie);
> > $cmd = "mv $borrowedMovie
> > $filename:@allParams[3]:$dateFormat:ute.$extension";
> > print "<p>command<br>$cmd<p>";
> > $failure = system($cmd);
> > print "<p>failure: $failure<p>";
> > ------------------------
>
> I do hope that $borrowedMovie, $allParams[3], and $dateFormat aren't
> obtained directly from a web form.
But I think it is; please if you have the time visit the page
http://www.stud.ifi.uio.no/~johanba/dvd/
I am sure this can be done much more compact and with better code, this is
however my first attempt to make anything interactive from scratch. I'm just
trying to make something usefull; an index of dvds that I have currently
borrowed to friends.
JHWB
------------------------------
Date: 10 Oct 2001 08:17:51 -0700
From: gthorne@bitweever.com (Greg Thorne)
Subject: Keeping an escape code in a line
Message-Id: <9e243fc1.0110100717.59bfb96f@posting.google.com>
I have (what seems like) a very straightforward and easy question.
Consider the following code:
while (<>)
{
print "You typed: $_";
}
This is some pretty easy code, and if you type 'test123' and hit
enter, it says 'You typed: test123' on the next line.
However, this is the problem that I'm running into: if I type
'test123\t\n' it outputs 'You typed: test123\t\n' and does not expand
the \t and \n into tab and carriage return. Now, if I DID want them
expanded, how would I do that? I ask this because I have a script
using a 'while (<>)' that reads from a file, and the file contains
space-delimited waitfor/send pairs to use in an expect script. So,
the file may look like:
Username: user001\n Password: pass12345\n
And when the 'send' lines are printed to the remote device, they're
printed as 'user001\n' and not 'user001<CR>'
Thank you for any help you could give on this issue.
+--
Greg Thorne
gthorne<at>bitweever<dot>com
perl -e '$|=1;foreach(unpack("A2"x9,hex("3CA28229").hex("CAF64E"))){print"1";
for($n=97;$n<$_+89;$n++){printf("\b%c",$n);select($u,$u,$u,.05);}}print"\n";'
------------------------------
Date: Wed, 10 Oct 2001 15:32:26 -0000
From: blah@blah.blah.invalid
Subject: Re: Keeping an escape code in a line
Message-Id: <ts8qga4qh1l5d1@corp.supernews.com>
Greg Thorne <gthorne@bitweever.com> wrote:
> I have (what seems like) a very straightforward and easy question.
> Consider the following code:
>
> while (<>)
> {
> print "You typed: $_";
> }
[ ... ]
> However, this is the problem that I'm running into: if I type
> 'test123\t\n' it outputs 'You typed: test123\t\n' and does not expand
> the \t and \n into tab and carriage return. Now, if I DID want them
> expanded, how would I do that? I ask this because I have a script
[ cut ]
Dunno how well it fits in with your application, but you can wrap
an 'eval' around the print:
while (<>) {
eval "print qq($_)";
}
--
Eric Wong
eric+pgp@taedium.com http://www.taedium.com/pgp.txt
------------------------------
Date: Wed, 10 Oct 2001 18:48:11 +0200
From: "Jean-Philippe AVELANGE" <Jean-Philippe.AVELANGE@cgey.com>
Subject: Re: Keeping an escape code in a line
Message-Id: <3bc47c16$0$12994$626a54ce@news.free.fr>
Try
while (<>)
{
print eval( "\"You typed: $_\"" );
}
Jean-Philippe.
----- Original Message -----
From: "Greg Thorne" <gthorne@bitweever.com>
Newsgroups: comp.lang.perl.misc
Sent: Wednesday, October 10, 2001 5:17 PM
Subject: Keeping an escape code in a line
> I have (what seems like) a very straightforward and easy question.
> Consider the following code:
>
> while (<>)
> {
> print "You typed: $_";
> }
>
> This is some pretty easy code, and if you type 'test123' and hit
> enter, it says 'You typed: test123' on the next line.
>
> However, this is the problem that I'm running into: if I type
> 'test123\t\n' it outputs 'You typed: test123\t\n' and does not expand
> the \t and \n into tab and carriage return. Now, if I DID want them
> expanded, how would I do that? I ask this because I have a script
> using a 'while (<>)' that reads from a file, and the file contains
> space-delimited waitfor/send pairs to use in an expect script. So,
> the file may look like:
> Username: user001\n Password: pass12345\n
> And when the 'send' lines are printed to the remote device, they're
> printed as 'user001\n' and not 'user001<CR>'
>
> Thank you for any help you could give on this issue.
>
>
> +--
>
> Greg Thorne
> gthorne<at>bitweever<dot>com
>
> perl -e
'$|=1;foreach(unpack("A2"x9,hex("3CA28229").hex("CAF64E"))){print"1";
>
for($n=97;$n<$_+89;$n++){printf("\b%c",$n);select($u,$u,$u,.05);}}print"\n";
'
------------------------------
Date: 10 Oct 2001 18:16:14 +0100
From: nobull@mail.com
Subject: Re: Keeping an escape code in a line
Message-Id: <u93d4rl8kh.fsf@wcl-l.bham.ac.uk>
"Jean-Philippe AVELANGE" <Jean-Philippe.AVELANGE@cgey.com> writes in
untrimmed jeopardy style which is a _big_ clue that what he says
should be taken with a large pinch of salt:
> "Greg Thorne" <gthorne@bitweever.com> wrote:
>>
> > while (<>)
> > {
> > print "You typed: $_";
> > }
> > However, this is the problem that I'm running into: if I type
> > 'test123\t\n' it outputs 'You typed: test123\t\n' and does not expand
> > the \t and \n into tab and carriage return. Now, if I DID want them
> > expanded, how would I do that?
> print eval( "\"You typed: $_\"" );
Be aware that this also expands $ and @ interpoations in $_ and thus
must not be used if the input is comming from someone who should not
have the right to execute arbitrary commands on your system. (Or
indeed if the input contains unescaped $ or @ that you don't want to
treat as interpoations).
Futhermore the above solution barfs if there are double quotes in the
string. If you do want to use eval() to expand escapes and
interpolations the conventional technique is:
chop ( $_ = eval "<<__EndOfData__\n$_\n__EndOfData__\n" );
if ( $@ ) {
print "You typed something that caused error $@";
} else {
print "You typed: $_";
}
This assumes that the string does not contain "\n__EndOfData__\n".
This is usually a safe assuption.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 10 Oct 2001 08:08:35 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Need help - pragmatic modules not available
Message-Id: <3BC44853.C87BAFF4@home.com>
RoJo wrote:
>
> I have been running ActiveState's Perl on my Win2000 Prof'l
> workstation. But the Perl running on the MindSpring server
> sometimes returns "500 Server Error" or "Cannot display page".
> I'm operating almost blind, trying to diagnose them because these
> errors do NOT get flagged in ActivePerl. That's why I wish I
> could run compiles on the server.
Those aren't Perl errors -- they come from the web server. They *might*
be a symptom of a syntax error in your script, but it could also be a
sign that you've made a logic error in your program. They aren't
terribly helpful, though, which is why there's this module:
use CGI::Carp qw(fatalsToBrowser);
Which redirects fatal error messages to the web browser. Read the
documentation and give it a try.
> I've tried the use PSI::ESP; you suggested, but it errors out.
That's, uh, not a real module. (Though we could wish that it was.)
PSI::ESP is a mythical module that the folks on this newsgroup use to
try to figure out what a person's problem is when they haven't stated it
clearly. Saying 'use PSI::ESP' is a tongue-in-cheek way of saying "I'm
trying to read your mind."
Thanks for the chuckle, though. :)
> I need the data on a real web server because it's for an app that
> I want to run anywhere, using any current-technology browser. A
> standalone web server cannot fill that need.
You misunderstand me; I suggested installing your own web server to aid
in the development. It can be much easier to debug when you can do it
locally instead of having to upload your changes to a remote server
every time. Once it works locally you can upload it to its final home.
-mjc
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 1904
***************************************