[25765] in Perl-Users-Digest
Perl-Users Digest, Issue: 8004 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 21 18:10:21 2005
Date: Thu, 21 Apr 2005 15:10:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 21 Apr 2005 Volume: 10 Number: 8004
Today's topics:
perl doesn't recogize alias? (Jianping Wu)
Re: perl doesn't recogize alias? <postmaster@castleamber.com>
Re: perl doesn't recogize alias? <nospam@bigpond.com>
Re: perl doesn't recogize alias? <matternc@comcast.net>
Re: perl doesn't recogize alias? <axel@white-eagle.invalid.uk>
Re: perl doesn't recogize alias? <kkeller-usenet@wombat.san-francisco.ca.us>
Re: Problem with setting LD_LIBRARY_PATH <moritz.karbach@desy.de>
Re: Problem with setting LD_LIBRARY_PATH <moritz.karbach@desy.de>
Saving a compiled source file with the "require"d files <izombe@yahoo.com>
Re: Saving a compiled source file with the "require"d f xhoster@gmail.com
Re: Saving a compiled source file with the "require"d f <izombe@yahoo.com>
system() with 2 commands <michael.n.palassis@gmail.com>
Re: system() with 2 commands <axel@white-eagle.invalid.uk>
Re: system() with 2 commands <nospam@bigpond.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 21 Apr 2005 14:00:36 -0700
From: jianpingw@gmail.com (Jianping Wu)
Subject: perl doesn't recogize alias?
Message-Id: <bdaef5ca.0504211300.64acb62f@posting.google.com>
Hi, I am confused by the following problem:
On bash shell, I did:
alias gcc='grep'
Then I wrote a perl script with only one line:
`gcc -v`;
On bash shell, if I type "gcc -v", I got:
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
This is correct because gcc is aliased to grep.
But when I run the perl script, I got:
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --disable-libunwind-exceptions --with-system-zlib
--enable-__cxa_atexit --host=i386-redhat-linux
Thread model: posix
gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7)
How come Perl doesn't recognize the aliasing?
Thanks for your help!
Jianping
------------------------------
Date: 21 Apr 2005 21:14:42 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: perl doesn't recogize alias?
Message-Id: <Xns963FA4EF748B0castleamber@130.133.1.4>
Jianping Wu wrote:
> Hi, I am confused by the following problem:
>
> On bash shell, I did:
> alias gcc='grep'
>
> Then I wrote a perl script with only one line:
> `gcc -v`;
>
> On bash shell, if I type "gcc -v", I got:
> Usage: grep [OPTION]... PATTERN [FILE]...
> Try `grep --help' for more information.
>
> This is correct because gcc is aliased to grep.
> But when I run the perl script, I got:
> Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
> --infodir=/usr/share/info --enable-shared --enable-threads=posix
> --disable-checking --disable-libunwind-exceptions --with-system-zlib
> --enable-__cxa_atexit --host=i386-redhat-linux
> Thread model: posix
> gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7)
>
> How come Perl doesn't recognize the aliasing?
Quick guess: ` ` runs in it's own shell, e.g. if you open up another xterm
/ shell, and type gcc -v you get the same message.
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: Fri, 22 Apr 2005 07:19:23 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: perl doesn't recogize alias?
Message-Id: <426818c9_2@x-privat.org>
Jianping Wu wrote:
> Hi, I am confused by the following problem:
>
> On bash shell, I did:
> alias gcc='grep'
>
> Then I wrote a perl script with only one line:
> `gcc -v`;
>
> On bash shell, if I type "gcc -v", I got:
> Usage: grep [OPTION]... PATTERN [FILE]...
> Try `grep --help' for more information.
>
> This is correct because gcc is aliased to grep.
> But when I run the perl script, I got:
> Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
> --infodir=/usr/share/info --enable-shared --enable-threads=posix
> --disable-checking --disable-libunwind-exceptions --with-system-zlib
> --enable-__cxa_atexit --host=i386-redhat-linux
> Thread model: posix
> gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7)
Which is the correct output. perl -v shows the version.
> How come Perl doesn't recognize the aliasing?
Alias is a shell cooncept. Nothing to do with Perl. It works as expected.
Don't you have anything better to do with your time?
gtoomey
------------------------------
Date: Thu, 21 Apr 2005 17:21:59 -0400
From: Chris Mattern <matternc@comcast.net>
Subject: Re: perl doesn't recogize alias?
Message-Id: <4fidncQpkdLqhPXfRVn-tg@comcast.com>
Jianping Wu wrote:
> Hi, I am confused by the following problem:
>
> On bash shell, I did:
> alias gcc='grep'
>
> Then I wrote a perl script with only one line:
> `gcc -v`;
Perl has a rule about how it handles backticks (and similar calling
of external programs). If it has shell metacharacters in it, it
passes the string to /bin/sh. If it doesn't, it passes the string
to exec(). Your example gets passed to exec(), so no shell aliases
for you!
>
> On bash shell, if I type "gcc -v", I got:
> Usage: grep [OPTION]... PATTERN [FILE]...
> Try `grep --help' for more information.
>
> This is correct because gcc is aliased to grep.
> But when I run the perl script, I got:
> Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
> --infodir=/usr/share/info --enable-shared --enable-threads=posix
> --disable-checking --disable-libunwind-exceptions --with-system-zlib
> --enable-__cxa_atexit --host=i386-redhat-linux
> Thread model: posix
> gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7)
>
> How come Perl doesn't recognize the aliasing?
Because it doesn't pass it to the shell.
>
> Thanks for your help!
>
> Jianping
--
Christopher Mattern
"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
------------------------------
Date: Thu, 21 Apr 2005 16:49:25 -0500
From: Axel <axel@white-eagle.invalid.uk>
Subject: Re: perl doesn't recogize alias?
Message-Id: <sKqdnbDQrqd4gvXfRVn-jw@adelphia.com>
Chris Mattern <matternc@comcast.net> wrote:
>> On bash shell, I did:
>> alias gcc='grep'
>> Then I wrote a perl script with only one line:
>> `gcc -v`;
> Perl has a rule about how it handles backticks (and similar calling
> of external programs). If it has shell metacharacters in it, it
> passes the string to /bin/sh. If it doesn't, it passes the string
> to exec(). Your example gets passed to exec(), so no shell aliases
> for you!
Even using shell metacharacters would not help since the alias would not
be inherited.
I suppose you could place the alias in a startup file, remembering
that the behaviour of bash in reading startup files differs according
to whether it is invoked by the name 'sh' or 'bash'.
Axel
------------------------------
Date: Thu, 21 Apr 2005 14:44:35 -0700
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: perl doesn't recogize alias?
Message-Id: <4fjlj2xtb1.ln2@goaway.wombat.san-francisco.ca.us>
On 2005-04-21, Gregory Toomey <nospam@bigpond.com> wrote:
> Jianping Wu wrote:
>
>> Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
>> --infodir=/usr/share/info --enable-shared --enable-threads=posix
>> --disable-checking --disable-libunwind-exceptions --with-system-zlib
>> --enable-__cxa_atexit --host=i386-redhat-linux
>> Thread model: posix
>> gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7)
>
> Which is the correct output. perl -v shows the version.
Small nitpick: the above is the output for gcc -v, not perl -v (or
perl -V).
--keith
--
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
see X- headers for PGP signature information
------------------------------
Date: Thu, 21 Apr 2005 20:18:32 +0200
From: Moritz Karbach <moritz.karbach@desy.de>
Subject: Re: Problem with setting LD_LIBRARY_PATH
Message-Id: <d48qsh$2fb62$1@claire.desy.de>
Steven Kuo wrote:
> Forgot that the output from `pwd` includes newline at the end?
Aaaarrg! That was exactly the problem! So f** simple! And I spent hours in
googling before I asked here...
Thanks a lot,
- Moritz
------------------------------
Date: Thu, 21 Apr 2005 20:18:32 +0200
From: Moritz Karbach <moritz.karbach@desy.de>
Subject: Re: Problem with setting LD_LIBRARY_PATH
Message-Id: <d48qpo$2ek4l$1@claire.desy.de>
Steven Kuo wrote:
> Forgot that the output from `pwd` includes newline at the end?
Aaaarrg! That was exactly the problem! So f** simple! And I spent hours in
googling before I asked here...
Thanks a lot,
- Moritz
------------------------------
Date: 21 Apr 2005 14:27:36 -0700
From: "Ray Muforosky" <izombe@yahoo.com>
Subject: Saving a compiled source file with the "require"d files
Message-Id: <1114118856.710383.110580@l41g2000cwc.googlegroups.com>
Help.
If I have file1 that loads (require file2 and files), is it possible
save the content of file file after the load.
example:
file1
#!perl
$a =12;
require file2;
$b = $z;
require file3;
$c = $y;
print $a;
file2
$z = 200;
1;
file3
$y = "foo";
1;
So, is it possible to save file1 after loading file2 and file3
file1 becomes:
#!perl
$a =12;
$z = 200;
$b = $z;
$y = "foo";
$c = $y;
print $a;
Thanks
Ray
------------------------------
Date: 21 Apr 2005 21:30:02 GMT
From: xhoster@gmail.com
Subject: Re: Saving a compiled source file with the "require"d files
Message-Id: <20050421173002.975$V8@newsreader.com>
"Ray Muforosky" <izombe@yahoo.com> wrote:
> Help.
Please pick one appropriate subject line, and then stick with it.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 21 Apr 2005 14:42:46 -0700
From: "Ray Muforosky" <izombe@yahoo.com>
Subject: Re: Saving a compiled source file with the "require"d files
Message-Id: <1114119766.750670.222400@g14g2000cwa.googlegroups.com>
My apologies, I thought the first subject was not proper.
------------------------------
Date: 21 Apr 2005 13:25:37 -0700
From: "sitnam81" <michael.n.palassis@gmail.com>
Subject: system() with 2 commands
Message-Id: <1114115137.879793.61110@o13g2000cwo.googlegroups.com>
Base question
--------
Is there a way to perform 2 commands via system()? I would like to
execute a "sudo - root" and then "useradd" (or perhaps a script that
does the "useradd")?
Details
-------
I am relatively new to perl, and I am writing a cgi-script that will be
a front end for adding a user -- it takes input from a form (username,
UID, group, password) and performs in a loop across other servers:
system("ssh", "-l", $user, "-q", $SERVER{$loop}, $addcommand, "| 2>&1
>/dev/null");
I was able to get this working, but the $addcommand is a simple "cat of
a file into a temp file" to confirm it works. I need to perform a
"useradd" with all the options as the root user. The script is run as
a different user, so I will need to su to root (add su - root in
sudoers), and then perform the "useradd" command passing all the
arguements.
------------------------------
Date: Thu, 21 Apr 2005 16:22:14 -0500
From: Axel <axel@white-eagle.invalid.uk>
Subject: Re: system() with 2 commands
Message-Id: <tN6dnZ9Kne4bhPXfRVn-hg@adelphia.com>
sitnam81 <michael.n.palassis@gmail.com> wrote:
> Base question
> --------
> Is there a way to perform 2 commands via system()? I would like to
> execute a "sudo - root" and then "useradd" (or perhaps a script that
> does the "useradd")?
I think you may be confusing 'su' and 'sudo'. With the latter, the
command to be executed is provided at the same time:
sudo -u root useradd
Where you will run into problems is when the stage when you asked for
the root password.
You should look at the Expect.pm module.
Axel
------------------------------
Date: Fri, 22 Apr 2005 07:23:58 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: system() with 2 commands
Message-Id: <426819db_2@x-privat.org>
sitnam81 wrote:
> Base question
> --------
> Is there a way to perform 2 commands via system()? I would like to
> execute a "sudo - root" and then "useradd" (or perhaps a script that
> does the "useradd")?
>
> Details
> -------
> I am relatively new to perl, and I am writing a cgi-script that will be
> a front end for adding a user -- it takes input from a form (username,
> UID, group, password) and performs in a loop across other servers:
>
> system("ssh", "-l", $user, "-q", $SERVER{$loop}, $addcommand, "| 2>&1
>>/dev/null");
>
> I was able to get this working, but the $addcommand is a simple "cat of
> a file into a temp file" to confirm it works. I need to perform a
> "useradd" with all the options as the root user. The script is run as
> a different user, so I will need to su to root (add su - root in
> sudoers), and then perform the "useradd" command passing all the
> arguements.
system('command1;command2');
System just passes its arguments to your default shell. You can then use the
usual shell programming constructs.
You many have to be a bit careful if you are doing redirections like your
example, but no more so than if you are doing shell programming.
gtoomey
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 8004
***************************************