[8808] in Perl-Users-Digest
Perl-Users Digest, Issue: 2425 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 27 01:07:28 1998
Date: Sun, 26 Apr 98 22:00:22 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 26 Apr 1998 Volume: 8 Number: 2425
Today's topics:
Help! FCNTL Problems: Solaris 2.6 (Duncan D. Sterling)
Re: Parsing HTML ... (Martien Verbruggen)
Re: Perl and crypt command help please <webmaster@fccjmail.fccj.org>
Re: Perl and crypt command help please <rjk@coos.dartmouth.edu>
Re: Perl and crypt command help please (Martien Verbruggen)
Re: Perl and crypt command help please <danboo@negia.net>
Re: Perl experts!! help me!! (Martien Verbruggen)
Re: Perl-only distribution <rra@stanford.edu>
Re: Perl-only distribution <tchrist@mox.perl.com>
Re: Perl-only distribution <rra@stanford.edu>
Re: Perl-only distribution <uri@sysarch.com>
Re: Perl-only distribution (Martien Verbruggen)
Re: removing spaces (Martien Verbruggen)
Re: RFI: Counting repeated substrings within a string <newsgroups@reza.net>
Re: Shopping Cart in Perl <jhoglund@mirage.skypoint.net>
Re: Why doesn't this work? <rjk@coos.dartmouth.edu>
Re: Why doesn't this work? <uri@sysarch.com>
Re: Win32 & Process listing <kflanagan@home.com>
Win32 .lib vs .pll <brhess@email.msn.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 27 Apr 1998 03:33:49 GMT
From: buffalo@Radix.Net (Duncan D. Sterling)
Subject: Help! FCNTL Problems: Solaris 2.6
Message-Id: <6i0uat$5ja$1@news1.Radix.Net>
I'm in the process of setting up the latest stable version of Perl
on a Sun ultra 2 running Solaris 2.6.
Perl seems to compile OK, but when I do a "make test" I see only
an 83% success rate, with 21 tests failing.
The most critical problem of them all is with fcntl, which is
essential to most of the scripts I'm planning on transfering to this
machine.
Is there a patch for either Perl or Solaris that fixes this problem?
I haven't found any references on CPAN, or Sun sites...
TIA,
--Duncan
------------------------------
Date: 27 Apr 1998 02:59:20 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Parsing HTML ...
Message-Id: <6i0sa8$85e$2@comdyn.comdyn.com.au>
In article <6i0q6j$8ro$1@gaia.ns.utk.edu>,
"Bob Gwynne" <gwynne@utkux.utk.edu> writes:
> Get the LWP modules from CPAN.
I think that the HTML Parser isn't included in LWP anymore, but is
distributed separately. Also pick up HTML::Parser from CPAN, when you
go there.
# perl -MCPAN -e shell
cpan shell -- CPAN exploration and modules installation (v1.36)
ReadLine support enabled
cpan> i HTML::Parser
Module id = HTML::Parser
CPAN_USERID GAAS (Gisle Aas)
CPAN_VERSION 2.16
CPAN_FILE GAAS/HTML-Parser-2.16.tar.gz
MANPAGE HTML::Parser - SGML parser class
INST_FILE /usr/local/lib/perl5/site_perl/HTML/Parser.pm
INST_VERSION 2.16
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: Mon, 27 Apr 1998 03:12:19 GMT
From: Bill 'Sneex' Jones <webmaster@fccjmail.fccj.org>
To: Joshua Lippiner <jlippiner@iname.com>
Subject: Re: Perl and crypt command help please
Message-Id: <3543F5E9.59CA9C22@fccjmail.fccj.org>
[Mailed and Posted]
Joshua Lippiner wrote:
>
> Hello. I have been trying to implement a simple password, check password
> function that is not working right using the crypt command. I am using
> input from a web form. The input line is this;
>
> $thing[3] = crypt($inputs{'Password'}, substr($inputs{'Password'}, 0, 2));
>
> Where $thing[3] is then saved in a text file. To check the password is have
> this procedure;
>
> # Subprocedure to delete WD Information
> sub delete_WD {
> local(@thing) = @_;
> $UID=$thing[0];
> $PW=$thing[1];
>
> open (FILE, "$file");
> @lines = <FILE>;
>
> $j=0;
> foreach $linedata (@lines)
> {
> @line = split (/\|/,$linedata);
> $maybe_user = $line[0];
> $maybe_pw = $line[1];
> $test_passwd = crypt($PW, substr($maybe_pw, 0, 2));
> print "Test UID: $UID| Test PW: $PW| --> $test_passwd|\n";
> print "Line: $j, UID: $maybe_user| PW: $maybe_pw|\n\n";
> if ($test_passwd eq $maybe_pw && $UID eq $maybe_user) # this is line
> to check.
> { etc...
>
> I also tried this for $test_passwd;
> $test_passwd = crypt($PW, substr($PW, 0, 2));
>
> but neither is working. What can I do to make this type of thing work?
>
> thanks
>
> -josh
>
> please respond to jlippiner@iname.com
Back when I just started using Perl for SysAdmin work, I had the below
script to add students. It works 'as-is' for Solaris and may need
some changes to work on other platforms which support /etc/shadow;
so if your platform doesn't support /ect/shadow it will need to
be modified.
WARNING: I don't recommend using it, there are better ways which
involve TCL/Expect or upgrading to 5.004_04 and Using Expect.pm. So
use it at your own risk. I will not support it and I doubt any sane
person in this group will either.
I didn't originally write it; it was a hack from an old Perl book.
I just hacked it up some more...
-Sneex-
____________________________________________________________________________
Bill Jones | FCCJ Webmaster | Voice 1-904-632-3089 | Fax 1-904-632-3007
Florida Community College at Jacksonville | 501 W. State St. | Jax, FL 32202
mailto:webmaster@fccjmail.fccj.org | http://webmaster.fccj.org/Webmaster
PS - Who said I was sane?
Here is the code:
#!/usr/local/bin/perl -w
if ($ENV{"IFS"}) {
$ENV{"IFS"} = "";
}
$ENV{"PATH"} = "/bin:/usr/bin:/usr/ucb";
umask(022);
$| = 1;
($> == 0) || die "Must be running as root\n";
chdir "/etc" || die "Can't cd to /etc, $!\n";
unlink("passwd.adduser");
system("cp /etc/passwd /etc/passwd.adduser");
srand(time|$$);
for $i (97..122) {
push (@Pchars,sprintf ("%c",$i));
}
$Psize = scalar(@Pchars);
@Schars = ("a".."z","A".."Z","0".."9",".","/");
$Ssize = scalar(@Schars);
$SIG{"INT"} = "ABORT";
$SIG{"QUIT"} = "ABORT";
$SIG{"HUP"} = "ABORT";
$SIG{"PIPE"} = "ABORT";
$PtmpTmp = "ptmp$$";
open(PTMPTMP,">$PtmpTmp") || die "Can't create temporary passwd file, $!\n";
close(PTMPTMP);
for ($i=1;$i<=60;$i++) {
$GotPtmp = link($PtmpTmp,"ptmp");
if ($GotPtmp) {
unlink $PtmpTmp;
($i == 1) || print "\n"; # If no dots, no newline
last;
}
($i == 1) && print "Waiting for lock on /etc/passwd\n";
print ".";
sleep 1;
}
$GotPtmp || &ABORT("\nCan't get lock on /etc/passwd");
$StmpTmp = "stmp$$";
open(STMPTMP,">$StmpTmp") || die "Can't create temporary shadow file, $!\n";
close(STMPTMP);
for ($i=1;$i<=60;$i++) {
$GotStmp = link($StmpTmp,"stmp");
if ($GotStmp) {
unlink $StmpTmp;
($i == 1) || print "\n"; # If no dots, no newline
last;
}
($i == 1) && print "Waiting for lock on /etc/shadow\n";
print ".";
sleep 1;
}
$GotStmp || &ABORT("\nCan't get lock on /etc/shadow");
$SmallestUid = 100;
$SmallestGid = 100;
open(PASSWD,"passwd") || &ABORT("Can't open /etc/passwd, $!");
open(PTMP,">ptmp") || &ABORT("Can't open /etc/ptmp, $!");
open(GROUP,"group") || &ABORT("Can't open /etc/group, $!");
open(GTMP,">gtmp") || &ABORT("Can't open /etc/gtmp, $!");
open(SHADOW,"shadow") || &ABORT("Can't open /etc/shadow, $!");
open(STMP,">stmp") || &ABORT("Can't open /etc/stmp, $!");
$UidIndex = 0;
$GidIndex = 0;
while (<PASSWD>) {
print PTMP;
($Login,$Passwd,$Uid,$Gid) = split(":",$_,5);
$LoginSeen{$Login} = 1;
$UidSeen{$Uid} = 1;
if ($Uid >= $SmallestUid) {
$Uids[$UidIndex++] = $Uid;
}
}
close(PASSWD);
while (<GROUP>) {
($Group,$Passwd,$Gid,$Members) = split(":");
$GroupSeen{$Group} = 1;
$GidSeen{$Gid} = 1;
if ($Gid >= $SmallestGid) {
$Gids[$GidIndex++] = $Gid;
}
}
close(GROUP);
while (<SHADOW>) {
print STMP $_;
}
close(SHADOW);
while(<>) {
chop;
($Login,$RealName,$ClearPasswd,$Shell,$Home,$Uid,$Gid) = split(":");
$Login || next;
if ($LoginSeen{$Login}) {
print "$Login already in use .. skipping\n";
next;
}
$LoginSeen{$Login} = 1;
if (! $ClearPasswd) {
for $i (1..8) {
$ClearPasswd .= $Pchars[int(rand($Psize))];
}
}
$Salt = "$Schars[int(rand($Ssize))]$Schars[int(rand($Ssize))]";
$Passwd = crypt($ClearPasswd,$Salt) || &ABORT("Cant run crypt, $!");
if (! $Shell) {
$Shell = "/bin/csh";
}
if (! $Home) {
$Home = "/export/home/students/$Login";
}
if (defined($Uid) && ($Uid ne "")) {
if ($UidSeen{$Uid}) {
print "$Uid alread in use .. skipping $Login\n";
next;
}
} else {
$Uid = $SmallestUid;
for $u (sort @Uids) {
($u == $Uid) || last;
$Uid++;
}
$UidSeen{$Uid} = 1;
push(@Uids,$Uid);
}
$Gid = 972;
if ((! defined($Gid)) || ($Gid eq "")) {
$Gid = $SmallestGid;
$OldG = $SmallestGid - 1;
for $g (sort @Gids) {
($g == $OldG) && next;
($g == $Gid) || last;
$Gid++;
$OldG = $g;
}
}
push(@Gids,$Gid);
if ($GidSeen{$Gid}) {
if ($ExistingGroupInfo{$Gid}) {
$ExistingGroupInfo{$Gid} .= ",$Login";
} else {
$ExistingGroupInfo{$Gid} = "$Login";
}
} else {
if ($NewGroupInfo{$Gid}) {
$NewGroupInfo{$Gid} .= ",$Login";
} else {
if ($GroupSeen{$Login}) {
print "$Login already used as a group name .. skipping\n";
next;
}
$NewGroupInfo{$Gid} = "$Login";
}
}
$Homes{$Home} = "$Uid:$Gid";
print PTMP "$Login:x:$Uid:$Gid:$RealName:$Home:$Shell\n";
print STMP "$Login:$Passwd:\n";
print "$Login has passwd ->$ClearPasswd<-\n";
}
close(PTMP);
close(STMP);
open(GROUP,"group") || &ABORT("Can't open /etc/group, $!");
while (<GROUP>) {
chop;
($Group,$Passwd,$Gid,$Members) = split(":");
if ($ExistingGroupInfo{$Gid}) {
if ($Members ne "") {
$Members .= ",";
}
$Members .= $ExistingGroupInfo{$Gid};
}
print GTMP join(":",$Group,$Passwd,$Gid,$Members), "\n";
}
close(GROUP);
for $Gid (sort keys %NewGroupInfo) {
($Group) = split(",",$NewGroupInfo{$Gid},2);
print GTMP join(":",$Group,"*",$Gid,$NewGroupInfo{$Gid}), "\n";
}
close(GTMP);
rename("shadow","shadow.old");
rename("stmp","shadow") || &ABORT("Can't install new shadow file, $!");
rename("group","group.old");
rename("gtmp","group") || &ABORT("Can't install new group file, $!");
rename("passwd","passwd.old");
rename("ptmp","passwd") || &ABORT("Can't install new password file, $!");
for $Home (keys %Homes) {
if (! (mkdir ($Home, 0755))) {
print "Can't create $Home\n";
next;
}
system("cp -r /etc/skel/* $Home");
($Uid,$Gid) = split(":",$Homes{$Home});
if (! (chown $Uid, $Gid, $Home)) {
print "Can't set ownership on $Home, $!\n";
next;
}
chmod 0755, $Home || print "Can't change modes on $Home, $!\n";
system("chown -R $Uid:$Gid $Home");
}
exit 0;
sub ABORT {
local($msg) = @_;
$GotPtmp && unlink "ptmp";
-f $PtmpTmp && unlink $PtmpTmp;
-f "gtmp" && unlink "gtmp";
-f "stmp" && unlink "stmp";
$msg && print "$msg";
print "\n\nAborting\n";
exit 1;
}
------------------------------
Date: Sun, 26 Apr 1998 23:20:27 -0400
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
To: Joshua Lippiner <jlippiner@iname.com>
Subject: Re: Perl and crypt command help please
Message-Id: <3543F97C.35695716@coos.dartmouth.edu>
[posted and mailed]
Joshua Lippiner wrote:
>
> $thing[3] = crypt($inputs{'Password'}, substr($inputs{'Password'}, 0, 2));
>
> $PW=$thing[1];
Why 3 before and 1 now?
> $test_passwd = crypt($PW, substr($maybe_pw, 0, 2));
Check out the entry for crypt in the perlfunc documentation, particularly the
code example. I believe you have the variables in the wrong order in your
second call to crypt.
BTW, Programming Perl 2ed says that "truncating the salt to two characters is
a waste of CPU time."
> I also tried this for $test_passwd;
> $test_passwd = crypt($PW, substr($PW, 0, 2));
That encrypts an already encrypted password. Not very useful.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J. Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 27 Apr 1998 02:55:10 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl and crypt command help please
Message-Id: <6i0s2e$85e$1@comdyn.comdyn.com.au>
In article <6i0psk$iog$1@winter.news.erols.com>,
"Joshua Lippiner" <jlippiner@iname.com> writes:
> Hello. I have been trying to implement a simple password, check password
> function that is not working right using the crypt command. I am using
> input from a web form. The input line is this;
>
> $thing[3] = crypt($inputs{'Password'}, substr($inputs{'Password'}, 0, 2));
>
> Where $thing[3] is then saved in a text file. To check the password is have
> this procedure;
General comments:
Did you run perl with the -w flag? Probably not.
You really should get in the habit of developing all your scripts with
the strict pragma, and -w enabled.
> # Subprocedure to delete WD Information
> sub delete_WD {
> local(@thing) = @_;
> $UID=$thing[0];
You know that $UID is a special perl variable? Check the perlvar man
page, and in general: avoid all uppercase variable names, unless you
know what you're doing.
# perldoc perlvar
> $PW=$thing[1];
You could have used $_[0] and $_[1] directly.
> open (FILE, "$file");
You should check wether your open was successful
The quotes don't do anything.
open(ZZZ, $file) || die "Cannot open $file: $!";
> @lines = <FILE>;
You should close the file.
> $j=0;
> foreach $linedata (@lines)
> {
> @line = split (/\|/,$linedata);
This is where the problem lies:
You do realise that your lines still end in a newline, right? That
means that after the split the last returned element still has a
newline attached to it. You might want to have a look at the chomp
builtin
# perldoc -f chomp
> $maybe_user = $line[0];
> $maybe_pw = $line[1];
Here $maybe_pw very likely ends in a newline.
> $test_passwd = crypt($PW, substr($maybe_pw, 0, 2));
Why do you do this inside of the loop? You only need to do that once.
Just crypt it the same way as you crypted it above. it should match.
> print "Test UID: $UID| Test PW: $PW| --> $test_passwd|\n";
> print "Line: $j, UID: $maybe_user| PW: $maybe_pw|\n\n";
> if ($test_passwd eq $maybe_pw && $UID eq $maybe_user) # this is line
> to check.
I would probably revert these two. First check to see if the uid
matches, then check to see if the passwd matches.
> please respond to jlippiner@iname.com
Post here, read here
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: Sun, 26 Apr 1998 23:03:09 -0400
From: Dan Boorstein <danboo@negia.net>
To: jlippiner@iname.com
Subject: Re: Perl and crypt command help please
Message-Id: <3543F56D.F3EE1AB7@negia.net>
Joshua Lippiner wrote:
>
> Hello. I have been trying to implement a simple password, check password
> function that is not working right using the crypt command. I am using
> input from a web form. The input line is this;
>
> $thing[3] = crypt($inputs{'Password'}, substr($inputs{'Password'}, 0, 2));
couple things to point out here. number one you don't have to manually
extract the two character string to be used as the salt. you could
just do:
$thing[3] = crypt($inputs{'Password'}, $inputs{'Password'});
and get the same result. second, using the password to encrypt the
password is going to give away information about the password to
potential intruders:
danboo% perl -e 'printf "%s\n", crypt "foo", "bar";'
ba4TuD1iozTxw
danboo%
note that the salt is the first two characters of the encrypted string.
i recommend incorporating a bit of randomness into the salt.
> Where $thing[3] is then saved in a text file. To check the password is have
> this procedure;
>
> # Subprocedure to delete WD Information
> sub delete_WD {
> local(@thing) = @_;
> $UID=$thing[0];
> $PW=$thing[1];
>
> open (FILE, "$file");
^^^^^^^^^^^^^^^^^^^^
are you sure the file opened?
> @lines = <FILE>;
>
> $j=0;
> foreach $linedata (@lines)
> {
> @line = split (/\|/,$linedata);
> $maybe_user = $line[0];
> $maybe_pw = $line[1];
> $test_passwd = crypt($PW, substr($maybe_pw, 0, 2));
> print "Test UID: $UID| Test PW: $PW| --> $test_passwd|\n";
> print "Line: $j, UID: $maybe_user| PW: $maybe_pw|\n\n";
> if ($test_passwd eq $maybe_pw && $UID eq $maybe_user) # this is line
> to check.
> { etc...
what other data is on each line? does $maybe_pw have a \n on the end?
so what are the results of your print statements? that would help
greatly in seeing what the problem is.
cheers,
--
Dan Boorstein home: danboo@negia.net work: danboo@y-dna.com
"THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."
- Cosmic AC
------------------------------
Date: 27 Apr 1998 03:03:20 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl experts!! help me!!
Message-Id: <6i0sho$85e$3@comdyn.comdyn.com.au>
In article <3543EF44.722F@juicepigs.com>,
Bob Trieger <sowmaster@juicepigs.com> writes:
> This is an excerpt from their homepage.
>
> findApp subjects :
>
> Programming Internet Servers
> Java IIS
> JavaScript ASP
> VisualBasic Apache
> C++ Netscape
> COM/ActiveX CGI/Perl
>
> They have absolutely no clue. Not only do they have a CGI/Perl category,
> but they think it is a server.
Heh. I missed that in the approximately 3 seconds that I took to
scan that page. Pity.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: 26 Apr 1998 20:09:45 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Perl-only distribution
Message-Id: <m31zukrmdi.fsf_-_@windlord.Stanford.EDU>
In comp.lang.perl.misc,
Shimpei Yamashita <shimpei+usenet+.mil+.gov@BOFH.patnet.caltech.edu> writes:
> More importantly, libc also calls /bin/sh in several locations (most
> notably in some of the exec() family of calls), so you will also need to
> patch libc.
I believe /bin/sh is only used in system() and popen() (and perhaps a few
other places). exec*() should only be running the binary that you
specifically told it to run.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: 27 Apr 1998 03:15:55 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Perl-only distribution
Message-Id: <6i0t9b$cad$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Russ Allbery <rra@stanford.edu> writes:
:I believe /bin/sh is only used in system() and popen() (and perhaps a few
:other places). exec*() should only be running the binary that you
:specifically told it to run.
Ah, no.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
Emacs is a fine programming language, but I still prefer perl.
------------------------------
Date: 26 Apr 1998 20:58:59 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Perl-only distribution
Message-Id: <m3vhrvrk3g.fsf@windlord.Stanford.EDU>
In comp.lang.perl.misc, Russ Allbery <rra@stanford.edu> writes:
> I believe /bin/sh is only used in system() and popen() (and perhaps a
> few other places). exec*() should only be running the binary that you
> specifically told it to run.
Doh. Ignore me. execlp() and execvp() will pass the contents of files
with unknown magic numbers to /bin/sh by default.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: 27 Apr 1998 00:27:31 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Perl-only distribution
Message-Id: <x7iunvdh3g.fsf@sysarch.com>
>>>>> "RA" == Russ Allbery <rra@stanford.edu> writes:
RA> In comp.lang.perl.misc, Shimpei Yamashita
RA> <shimpei+usenet+.mil+.gov@BOFH.patnet.caltech.edu> writes:
>> More importantly, libc also calls /bin/sh in several locations
>> (most notably in some of the exec() family of calls), so you will
>> also need to patch libc.
RA> I believe /bin/sh is only used in system() and popen() (and
RA> perhaps a few other places). exec*() should only be running the
RA> binary that you specifically told it to run.
exec will call /bin/sh if there are shell metachars in the single string
arg. multiple arg calls to exec bypass the shell. system uses the same
algorithm to decide to call the shell beforehand so it is not guaranteed
to use /bin/sh.
open seems to use the same check for metachars to decide if a shell is
called when opening a pipe e.g. open( F, '| foo | bar') will call the shell.
qx() or backticks will also call the shell to execute the command.
according to camel2 it always calls it unlike system and exec.
so there are many places perl uses the shell and it would be very
difficult to track them all down. if you replaced /bin/sh with a shell
script (maybe another shell!) it could be used to log any calls so you
could find the calls from perl.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---- 8 Years of Perl Experience, Available Immediately
uri@sysarch.com --------- Resume and Perl Example at http://www.sysarch.com
Use the Best Search Engine on the Net -------- http://www.northernlight.com
------------------------------
Date: 27 Apr 1998 03:43:58 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl-only distribution
Message-Id: <6i0utu$8er$1@comdyn.comdyn.com.au>
In article <m31zukrmdi.fsf_-_@windlord.stanford.edu>,
Russ Allbery <rra@stanford.edu> writes:
> In comp.lang.perl.misc,
> Shimpei Yamashita <shimpei+usenet+.mil+.gov@BOFH.patnet.caltech.edu> writes:
>
>> More importantly, libc also calls /bin/sh in several locations (most
>> notably in some of the exec() family of calls), so you will also need to
>> patch libc.
>
> I believe /bin/sh is only used in system() and popen() (and perhaps a few
> other places). exec*() should only be running the binary that you
> specifically told it to run.
To avoid confusion about perl builtins and system calls:
The perl functions:
# perldoc -f exec
[snip]
The exec() function executes a system command I<AND NEVER RETURNS> -
use system() instead of exec() if you want it to return. It fails and
returns FALSE only if the command does not exist I<and> it is executed
directly instead of via your system's command shell (see below).
[snip]
# perldoc -f system
Does exactly the same thing as "exec LIST" except that a fork is done
first, and the parent process waits for the child process to complete.
[snip]
The system calls (on Solaris, might be different on others:
# man execvp
[snip]
If the new process file is not an executable object file,
execlp() and execvp() use the contents of that file as standard
input to the shell. In a standard-conforming application (see
standards(5)), the exec family of functions use /usr/bin/ksh
(see ksh(1)); otherwise, they use /usr/bin/sh (see sh(1)).
[snip]
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: 27 Apr 1998 02:42:35 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: removing spaces
Message-Id: <6i0rar$834$1@comdyn.comdyn.com.au>
In article <6hpi5p$c8r$2@news.dknet.dk>,
steven@DK.net writes:
> Inge Soetens <soetensi@se.bel.alcatel.be> wrote:
>> Hi,
>
>> how can I remove all spaces from a line ?
>
> Wow! I read a reply to the *same* question posted only .. an hour ago!
That's because this question gets posted almost daily, with slight
variations:
'Removing spaces'
'How to remove blanks'
'Removing spaces from a variable'
'2 newbie questions'
'Question concerning regexp'
'How do I trim blanks'
'Stripping spaces'
'NEED HELP!!!!!!'
'Perl Guru needed for incredibly complex problem'
etc. etc.
And every time a thread develops with the same answers as were given
before, the same corrections, the same Benchmark tests, etc.
Martien
PS. Yes, I know that often these are questions about removing spaces
from the start or end of a variable, or both. That's even worse,
because it's answered in the FAQ.
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: Sun, 26 Apr 1998 21:35:58 -0700
From: Reza Naima <newsgroups@reza.net>
To: Alfred Landrum <agl3@cornell.edu>
Subject: Re: RFI: Counting repeated substrings within a string
Message-Id: <35440B2E.30EFFA89@reza.net>
Alfred Landrum wrote:
> Ex: An input of 'werasdwerasdwer' would return all of the times
> that 'wer', 'era', 'ras', 'asd' occured. (For the assignment, I'm just
> going to be looking at repeated patterns with 4 or more characters, then
> do some frequency study on the results to try and crack the cyphertext.)
>
Not that I like doing other people's homework, but this is a somewhat
interesting problem....
#!/usr/local/bin/perl
$i='werasdwerasdwer';
$chars = 3; # look at patters with 3 or more chars...
map {$count{substr $i, $_, $chars}++} ( 0 .. (length($i)-$chars));
print map {"$_ : $count{$_}\n"} keys %count;
zone:~ >perl /tmp/ct.pl
dwe : 2
asd : 2
era : 2
sdw : 2
ras : 2
wer : 3
You missed a few that were repeated. This can probably be optimized
a bit...
Reza
------------------------------
Date: 27 Apr 1998 04:37:19 GMT
From: Jamie Hoglund <jhoglund@mirage.skypoint.net>
Subject: Re: Shopping Cart in Perl
Message-Id: <6i121v$scd$1@shadow.skypoint.net>
tietzmann@yahoo.com wrote:
: Hello,
: I like to implement PerlShop on my web site, but I have some doubts:
: 1. Do I really need a main page containing a button like "Click Here to Start
: Shopping"?
: I've hundreds of product's pages on my web site, and I like to be able to
: make my users start shopping from any page.
: 2. I didn't understand the "Navigation Tag" very well. Do I need to have a
: preview and a next page for each of my page, or it's only an option?
It depends on what you want.
If you don't mind cookies, there are other carts available that allow you
to start at any page, I think the url is http://www.shopcites.com that
uses an IP number to get around the cookies, (but that approach has other
problems). The one I wrote uses cookies. Some people hate cookies though.
The problem is in something commonly referred to as the "state ID".
If you can figure out a way to get that magic ID number into the cart
program, than you should be able to use it anywhere.
Check out http://www.cgi-resources.com for a list of various shopping
cart software. I believe minivend has a "cookie option".
This is really a CGI issue more than a perl issue.
Jamie
------------------------------
Date: Sun, 26 Apr 1998 23:10:25 -0400
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: Why doesn't this work?
Message-Id: <3543F722.6AB1EA54@coos.dartmouth.edu>
Craig Berry wrote:
>
> $msg =~ s!((?:ftp|https?)://[\w&\-+?]+)!<a href="$1">$1</a>!gi;
You'd better allow a period in that character class too. Underscore would be
useful too, since it appears in many filenames. Perhaps %, too. And...
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J. Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 26 Apr 1998 23:14:45 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Why doesn't this work?
Message-Id: <x7ogxoc5wa.fsf@sysarch.com>
>>>>> "CB" == Craig Berry <cberry@cinenet.net> writes:
CB> Uri Guttman (uri@sysarch.com) wrote:
CB> : how about this one liner:
CB> :
CB> : #!/usr/local/bin/perl -n0
CB> : # run this with the file you want to extract meta as the arglist.
CB> : # redirect output to your favorite file
CB> :
CB> : while ( m/(<meta\s+[^>]+>)/ig ) { print "$1\n" ; }
CB> Or even more simply, replace the regex with
CB> m/(<meta\s+.+?>)/ig
nice try, but no cigar. this fails for newlines in the <meta>. . won't
match a newline without the /s modifier. either add /s to your regex or
use mine which will match any char other than a > and doesn't need the
nongreedy modifier.
also neither will match plain <meta> but that may not need to be found.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---- 8 Years of Perl Experience, Available Immediately
uri@sysarch.com --------- Resume and Perl Example at http://www.sysarch.com
Use the Best Search Engine on the Net -------- http://www.northernlight.com
------------------------------
Date: Mon, 27 Apr 1998 00:34:28 -0500
From: "Kevin Flanagan" <kflanagan@home.com>
Subject: Re: Win32 & Process listing
Message-Id: <6i11vu$6s7$1@ha2.rdc1.ne.home.com>
Igor Krivokon wrote in message <6hqnho$hm4$1@news.ncal.verio.com>...
>Gorm Haug Eriksen wrote in message ...
>>
>>hi,
>>
>>Someone know a way to list processes running on a Windows NT box?
>>
>>Seems like a pain in the a** according to the fact that this is not
>>listed in any faqs I have seen, and not described in any Win32 docs I
>>have looked at...?
If you need to do this in a perl script that's one thing, but if you just
need to
see from the command line then check for PS and PSTAT. They are command line
programs that I've had hanging around for so long I can't remember where
they came from.
------------------------------
Date: Mon, 27 Apr 1998 00:24:14 -0400
From: "Bill Hess" <brhess@email.msn.com>
Subject: Win32 .lib vs .pll
Message-Id: <ODKJBVZc9GA.215@uppubnews03>
I was using Activeware Perl 5.003 with two modules which had .pll files in
them. I am now using Standard Perl 5.004_04 and I want to use the two
modules with it.
I thought copying the files into the appropriate directories would work,
because I have done this successfully before in UNIX (with .so/.sl's of
course), but this was not the case on Win32.
I have noticed that all of the modules on the standard Perl 5.004 come with
.lib libraries and not .pll - What is the difference and should these be
treated differently?
Bill Hess
brhess@msn.com
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 2425
**************************************