[24481] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 6663 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 8 03:05:48 2004

Date: Tue, 8 Jun 2004 00:05:06 -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           Tue, 8 Jun 2004     Volume: 10 Number: 6663

Today's topics:
    Re: ANSI Screen escape sequences <Joe.Smith@inwap.com>
    Re: ANSI Screen escape sequences <usenet@morrow.me.uk>
    Re: call win32 API from linux perl script <lv@aol.com>
    Re: Need help installing WWW-Search-Ebay-2.193 Module.. <randy@theoryx5.uwinnipeg.ca>
    Re: Need help running shell commands <jurgenex@hotmail.com>
    Re: Need help running shell commands <tadmc@augustmail.com>
    Re: Need help running shell commands (jm)
    Re: Need help running shell commands <usenet@morrow.me.uk>
    Re: Need help running shell commands <tadmc@augustmail.com>
    Re: Need help running shell commands <Joe.Smith@inwap.com>
    Re: Perl Installation on Darwin <jgibson@mail.arc.nasa.gov>
    Re: Perl Installation on Darwin <spamtrap@dot-app.org>
    Re: syntax  $_[0] (Jon Landenburer)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 08 Jun 2004 04:49:09 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: ANSI Screen escape sequences
Message-Id: <9zbxc.56306$3x.11557@attbi_s54>

Ben Morrow wrote:

> use Term::ANSIScreen qw/:screen :cursor/;
> 
> locate 1, 1;
> cls;
> print "...";
> 
> For some reason I have found that both cls and clline only work for me
> if I locate to the start of the region to be cleared first.

That's a bug in your terminal emulator; it is not responding to escape
sequences as per the ANSI specs.

   cldown = "\x33[0J" = clear from location to end of screen
   clup   = "\x33[1J" = clear from beginning of screen to location
   cls    = "\x33[2J" = clear the entire screen

> presuming this is a bug in the linux console driver  :) .

Works fine with xterm, gnome-terminal, and the Linux 2.4.20 console.
	-Joe


------------------------------

Date: Tue, 8 Jun 2004 06:12:44 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: ANSI Screen escape sequences
Message-Id: <ca3lcr$q14$1@wisteria.csv.warwick.ac.uk>


Quoth Joe Smith <Joe.Smith@inwap.com>:
> Ben Morrow wrote:
> 
> > use Term::ANSIScreen qw/:screen :cursor/;
> > 
> > locate 1, 1;
> > cls;
> > print "...";
> > 
> > For some reason I have found that both cls and clline only work for me
> > if I locate to the start of the region to be cleared first.
> 
> That's a bug in your terminal emulator; it is not responding to escape
> sequences as per the ANSI specs.
> 
>    cldown = "\x33[0J" = clear from location to end of screen
>    clup   = "\x33[1J" = clear from beginning of screen to location
>    cls    = "\x33[2J" = clear the entire screen

I suspected as much. I didn't *really* think it likely that there would
be a bug in a module as simple as Term::ANSIScreen :).

> > presuming this is a bug in the linux console driver  :) .
> 
> Works fine with xterm, gnome-terminal, and the Linux 2.4.20 console.

Linux 2.6.3 console, in UTF-8 mode. I suspect the latter may be the
problem...

Ben

-- 
Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
   From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
(Ted Hughes,        [ Heracles shoots Vulture with arrow. Vulture bursts into ]
 /Alcestis/)        [ flame, and falls out of sight. ]         ben@morrow.me.uk


------------------------------

Date: Mon, 07 Jun 2004 21:41:51 -0500
From: l v <lv@aol.com>
Subject: Re: call win32 API from linux perl script
Message-Id: <40c527d7$1_5@corp.newsgroups.com>

Ben Morrow wrote:
> Quoth broutaf@yahoo.fr (broutard):
> 
>>I'm must calling an API from a remote win32 server in a perl script.
>>On a windows server, I use win32::OLE and it's work fine !
>>
>>But my perl script must run on a linux server and must call this win32 API !
>>Apparently, it's impossible to install win32::OLE on linux.
>>
>>So, how can i do ??
> 
> 
> AFAIK COM+ automation (OLE) doesn't allow you to interact with an object
> on another machine, so you would have the same problem calling an OLE
> function on one windows machine from another. What you need to do is set
> up a perl script that is always running on the Win32 machine, waiting
> for connections; then, when it receives one, it makes the OLE call and
> passes the results back to the other end. 
> 
> This sort of setup is called 'RPC' for 'Remote Procedure Call' and there
> are modules on CPAN which will handle both ends for you, for a variety
> of standard protocols. Try starting with RPC::Simple or XMLRPC::Lite.
> If none of these will fit your needs, for whatever reason, you will need
> to design your own protocol and implement a server for the Win32 box and
> a client for the linux box. Getting this sort of design right is not the
> easiest thing in the world, though, so you would be better off using one
> of the standard modules if you can.
> 
> Ben
> 

I once did something similar to this however I used http as the listener 
to run the windows perl script.  I needed to connect to an ODBC 
connection behind a firewall, port 80 was the only port open.  The unix 
server used LWP to *run* the win perl script via http.  The sql was 
passed in the url and the results were passed back as pairs of 
"key=value\n" which was quickly stored into a hash.  I still had to 
design my own protocol but that was what made the task fun to work on.

Len


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 100,000 Newsgroups - 19 Different Servers! =-----


------------------------------

Date: Mon, 7 Jun 2004 22:15:56 -0500
From: "Randy Kobes" <randy@theoryx5.uwinnipeg.ca>
Subject: Re: Need help installing WWW-Search-Ebay-2.193 Module...
Message-Id: <Obaxc.21052$gf1.51814@news1.mts.net>

"The Moor Of Venice" <grizelda_bone@yahool.com> wrote in message
   news:ku3xc.45022$_k3.1122038@bgtnsc05-news.ops.worldnet.att.net...
> Hi all.  I am trying to install the WWW-Search-Ebay-2.193 Module that I
> nicked off CPAN.  One of the O'Reilly Books has a script that calls this
> module.  Here's the problem:  I am trying to do it under Windows, from
> the Windows command line. <puts on flame proof suit and dodges rotten
> tomatoes>.
>
> It's not a pre-built module.  ActivePerl's PPM won't let me do it.
[ ... ]
What version of ActivePerl are you using? I just tried it on
a  box running ActivePerl 806, and a ppm package for
WWW-Search-Ebay (version 2.17) was found, and it
installed fine, including all the required dependencies.

best regards,
randy kobes





------------------------------

Date: Tue, 08 Jun 2004 01:16:44 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Need help running shell commands
Message-Id: <0s8xc.679$TJ6.69@nwrddc02.gnilink.net>

jm wrote:
> I have my perl file set up as 4711 and am running it as root.
>
> I simply want to change the path via the perl script:

You are not very clear about you are trying to do at all.
But I am guessing you are not talking about the path at all but you are
talking about the current working directory aka CWD.

> I have tried system('/mypath'); and system "/mypath";

Assuming your shell has such a shortcut command, that if a directory name is
entered instead of a command then it will change the CWD to that directory.
Then still you are changing the CWD for the forked system process only, not
for the process that is running the Perl script.

> When I set the path in the script, is it only set for the script
> itself (just for the script's usage)?

Using system() you are not changing anything for the script itself, but at
best for the process that is being forked to execute the command(s) listed
in the system() call.
If you want to chagne the cwd of the Perl process then use the chdir()
command.

> and thus it wouldn't change the
> path of the person running the script?

Child process cannot modify the environment (including the CWD) of the
parent process. Please see "perldoc -q environment".

jue




------------------------------

Date: Mon, 7 Jun 2004 21:38:16 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Need help running shell commands
Message-Id: <slrncca9ko.kfu.tadmc@magna.augustmail.com>

jm <john_20_28_2000@yahoo.com> wrote:

> When I set the path in the script, is it only set for the script
> itself (just for the script's usage)?  and thus it wouldn't change the
> path of the person running the script?


Right.

That is how it is _supposed_ to be.

A child process (perl) cannot affect the environment of its parent (sh).


See this Perl FAQ:

    I {changed directory, modified my environment} in a perl script.  
    How come the change disappeared when I exited the script?  
    How do I get my changes to be visible?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: 7 Jun 2004 19:51:52 -0700
From: john_20_28_2000@yahoo.com (jm)
Subject: Re: Need help running shell commands
Message-Id: <c67e4bdd.0406071851.1e00d745@posting.google.com>

Ben Morrow <usenet@morrow.me.uk> wrote in message news:<ca2nvn$a9f$3@wisteria.csv.warwick.ac.uk>...
> Quoth john_20_28_2000@yahoo.com (jm):
> > I have my perl file set up as 4711 and am running it as root.
> 
> Why? It sounds like you don't know Perl anywhere near well enough yet to
> be writing scripts to run setid.
> 
> > I simply want to change the path via the perl script:
> > 
> > I have tried system('/mypath'); and system "/mypath";
> > 
> > When I set the path in the script, is it only set for the script
> > itself (just for the script's usage)?  and thus it wouldn't change the
> > path of the person running the script?  Thank you.
> 
> Please explain yourself a little better.
> 
> Are you attempting to set $PATH in the invoking user's shell? This is a
> faq: perldoc -q environment
> 
> If you're trying to do something else, then I'm afraid I don't
> understand you at all. Try posting a short complete program, and
> explaining what it does that you don't want it to do (or what it doesn't
> do that you do want).
> 
> Ben


Sorry, I was in a hurry.  What I meant was:

system ('export PATH=/mypath:$PATH');
system ('. /mypath/myenvironment some_argc');

The problem is that I am using DBI and I have to be in a certain
environment to use it.  I can't just call DBI.  I have to set several
variables in the system (export myvar=myvalue) etc. and finally be in
a production environment before I can rund the DBI stuff in the Perl
script.

I apologize for the crazy code above.


------------------------------

Date: Tue, 8 Jun 2004 04:09:59 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Need help running shell commands
Message-Id: <ca3e6n$mhi$1@wisteria.csv.warwick.ac.uk>


Quoth john_20_28_2000@yahoo.com (jm):
> 
> Sorry, I was in a hurry.

When in a hurry explaining yourself clearly will *definitely* result in
quicker and more useful answers (if any) than being vague.

> What I meant was:
> 
> system ('export PATH=/mypath:$PATH');
> system ('. /mypath/myenvironment some_argc');
> 
> The problem is that I am using DBI and I have to be in a certain
> environment to use it.  I can't just call DBI.  I have to set several
> variables in the system (export myvar=myvalue) etc. and finally be in
> a production environment before I can rund the DBI stuff in the Perl
> script.

Right, that can't be done, as it stands. system forks a shell; this
shell cannot affect the working environment of the perl process.

You can change your environment variables yourself using the %ENV hash,
so for instance you can do

$ENV{PATH} = "/mypath:$ENV{PATH}";

 . You may find if this is for a DBD module that you need to do this in a
BEGIN block: certainly, I've found that with DBD::Sybase before.

Alternatively, if it is for some reason inconvenient to re-write the
shell script setting up the environment in Perl, you can wrap the perl
script in a shell script:

Move 'script' to 'script.pl'
Create a new file 'script' like 

#!/bin/sh

export PATH="/mypath:$PATH"
 . /mypath/myenvironment some_argc

perl /path/to/script.pl

A third way would be to do something like

/(.*?)=(.*)$/ and $ENV{$1} = $2 for qx{
    export PATH=...
    . /mypath/...
    env
};

if you can be sure nothing in your environment has a newline in it.

Ben

-- 
don't get my sympathy hanging out the 15th floor. you've changed the locks 3
times, he still comes reeling though the door, and soon he'll get to you, teach
you how to get to purest hell. you do it to yourself and that's what really
hurts is you do it to yourself just you, you and noone else ** ben@morrow.me.uk


------------------------------

Date: Mon, 7 Jun 2004 23:35:34 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Need help running shell commands
Message-Id: <slrnccaggm.n71.tadmc@magna.augustmail.com>

jm <john_20_28_2000@yahoo.com> wrote:


> Sorry, I was in a hurry. 


So you had hundreds or thousands of people trying to sort it all out?

That is an inefficient distribution of labor, please try not to do
that to us anymore.


>  What I meant was:
> 
> system ('export PATH=/mypath:$PATH');


   $ENV{PATH} = "/mypath:$ENV{PATH}";


> system ('. /mypath/myenvironment some_argc');


"myenvironment" is in a child process, so it inherits the environment
from its parent (perl), so it will have the modified path.


> The problem is that I am using DBI and I have to be in a certain
> environment to use it.  


That is not a problem.


> I have to set several
> variables in the system


see the %ENV hash in:

   perldoc perlvar


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Tue, 08 Jun 2004 05:01:27 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Need help running shell commands
Message-Id: <HKbxc.66043$Ly.34510@attbi_s01>

Gregory Toomey wrote:

> Ben Morrow wrote:
>>Quoth john_20_28_2000@yahoo.com (jm):
>>>I have my perl file set up as 4711 and am running it as root.
>>Please explain yourself a little better.
> 
> I dont have a clue what he wants. 4711 is a brand of aftershave.

You cut out the part where Ben shows that he knows exactly what it
means:
>> It sounds like you don't know Perl anywhere near well enough yet to
>> be writing scripts to run setid.

A script is made setUID=root via the unix command "chmod 4771 script.pl".
It's a dangerous and ill-advised thing to do, especially for newbies.
	-JOe



------------------------------

Date: Mon, 07 Jun 2004 18:14:39 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Perl Installation on Darwin
Message-Id: <070620041814391039%jgibson@mail.arc.nasa.gov>

In article <196cb7af.0405311524.3055020a@posting.google.com>, Jim
Keenan <jkeen_via_google@yahoo.com> wrote:

[intro snipped]

> Since I've never built Perl from source before, I'm wondering:  Has
> anyone written a primer on installation of Perl on Darwin, i.e., Perl
> on Darwin for Dummies (or, at least, for Beginners)?

You can find something of a primer on installing Perl 5.8.1 on a Mac
here:

http://developer.apple.com/internet/opensource/perl.html


------------------------------

Date: Mon, 07 Jun 2004 23:03:01 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Perl Installation on Darwin
Message-Id: <VuSdnZAwLdX6sVjdRVn-gQ@adelphia.com>

Jim Gibson wrote:

> You can find something of a primer on installing Perl 5.8.1 on a Mac
> here:
> 
> http://developer.apple.com/internet/opensource/perl.html

That article is *way* out of date, the stuff about the installation prefix
in particular.

It wasn't even very useful when it was first published - it was tested only
on a squeaky-clean install, and it showed. On a Jaguar system that had had
some CPAN modules installed under 5.6, the instructions as given resulted
in a mixture of CPAN modules for 5.6 and core modules for 5.8
under /Library/Perl.

Perl 5.8.4 comes with a readme.macosx document that is more accurate with
respect to the current release.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


------------------------------

Date: 7 Jun 2004 18:30:00 -0700
From: jon.m.landenburger@verizon.com (Jon Landenburer)
Subject: Re: syntax  $_[0]
Message-Id: <feee7535.0406071730.14e26141@posting.google.com>

Paul Lalli <lallip@dishwasher.cs.rpi.edu> wrote in message news:<20040607095533.H8971@dishwasher.cs.rpi.edu>...
> On Mon, 7 Jun 2004, Jon Landenburer wrote:
> 
> > I inherited a small perl program.  It has this syntax whjich I donnot
> > iunderstand.
> >
> > while (<FDF>)
> >     {
> >         $value = $_;
> >         if ($_[0])
> >          {   print TEMP $value;
> >              next;
> >          }
> >          $service_order = substr( $value, 21, 18);
> >          if ( $_[1] ) { $last_so = $service_order;}  ## record 1 force
> > feed
> >           .  .  .
> >           .  .  .
> >
> >
> > Its the $_[0] I dont understand.  If this were a subroutine I would
> > understand that tto be the first passed parameter.  But this is not a
> > subroutine .  I see the comment indicating that $_[1] but that line
> > never gets hit
> 
> Unless @_ is defined elsewhere in the program, in code you haven't shown
> us, this is non-sensical, and neither if statement should be executed.
> 
> Paul Lalli

Thanks Paul,  That was exactly my figuring.  I thought possibly it was
a piece of syntax I did not understand.  I have removed those
statements after testing and ,correctly, they do nothing.
Jonl


------------------------------

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 6663
***************************************


home help back first fref pref prev next nref lref last post