[19676] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1871 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 4 14:05:38 2001

Date: Thu, 4 Oct 2001 11:05:07 -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: <1002218707-v10-i1871@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 4 Oct 2001     Volume: 10 Number: 1871

Today's topics:
    Re: 2nd request pls-Embed sound to cgi? <s.warhurst@rl.ac.uk>
    Re: append column upon match (newbie) <darkon@one.net>
    Re: Can't unlink file under Perl for NT <glenn@surveystar.com>
    Re: Can't unlink file under Perl for NT (John J. Trammell)
        CGI form email oddness - not acting as expected (Jennifer)
    Re: CGI form email oddness - not acting as expected <joe+usenet@sunstarsys.com>
    Re: escape character for a space (John J. Trammell)
    Re: escape character for a space nobull@mail.com
    Re: get "REMOTE_ADDR" with perl.. <j.m.t.dowland@durham.ac.uk>
    Re: get "REMOTE_ADDR" with perl.. <JPFauvelle@Colt-Telecom.fr>
    Re: get "REMOTE_ADDR" with perl.. <gis88559@ultra2.cis.nctu.edu.tw>
    Re: get "REMOTE_ADDR" with perl.. nobull@mail.com
    Re: Help <darkon@one.net>
        How do I get byte count of retreived site using LWP::Us <john@tesserv.com>
        How to manipulate data from database (SAS)
        Need help to suppress STDOUT <tambaa@no.spam.yahoo.com>
    Re: Need help to suppress STDOUT <tony_curtis32@yahoo.com>
    Re: Need help to suppress STDOUT (John J. Trammell)
    Re: Need help to suppress STDOUT <tambaa@no.spam.yahoo.com>
    Re: Perl Guru needed for this extremely frustrating sea (Dan Boyce)
        Permission Denied Errors <jessica.bull@broadwing.com>
    Re: Permission Denied Errors <jeff@vpservices.com>
    Re: Permission Denied Errors <s.warhurst@rl.ac.uk>
    Re: Permission Denied Errors <thomas@baetzler.de>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 4 Oct 2001 17:26:58 +0100
From: "S Warhurst" <s.warhurst@rl.ac.uk>
Subject: Re: 2nd request pls-Embed sound to cgi?
Message-Id: <9pi2ki$hg2@newton.cc.rl.ac.uk>

"christo" <casey1@adelphia.net> wrote in message
news:0gsortsf8mfenjkommmotm1smto9gsh8eb@4ax.com...
> I have a free chat cgi script im running and would like to know if a
> beep sound can be embeded somehow to advise me when someone logs in to
> the chat room. any help would be appreciated.

The line:

printf("\a");

works in a script run from the console.




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

Date: Thu, 04 Oct 2001 17:16:14 -0000
From: David Wall <darkon@one.net>
Subject: Re: append column upon match (newbie)
Message-Id: <Xns913086E8BCD8Adarkononenet@207.126.101.97>

Jeff Zucker <jeff@vpservices.com> wrote on 03 Oct 2001:

> Michael Budash wrote:
>> 
>> In article <30688683.0110031022.3baabefb@posting.google.com>,
>> yus_punju@hotmail.com (Yugal Sharma) wrote: 
>> 
>> > Assuming I have a data_file that looks like this (space delimited):
>> >
>> > 1AKK  LYS     27      88      CA      3.7847    NZ    10.1088
>> > 1AKK  LYS     72      73      CA      3.8272    NZ    13.8547
>> > 1AKK  LYS     99      100     CA      3.8160    NZ    10.6881
>> >
>> > And I have an input_file that looks like this (space delimited):
>> >
>> > 72  73   16.4(BS3)
>> > 27  34   6.4(erg)
>> > 99  100  4.3(gsh)
>> >
>> > What I would like to do is compare the 1st and 2nd fields of the
>> > input_file to the 3rd and 4th fields of the data_file on a
>> > line-by-line basis.  If there is a match (on both fields), append
>> > the third field of the input_file as a last field to the data_file.
>> >  If there is no match, do not append anything.
>> >
>> > So, for example, comparing the input_file to the data_file above
>> > would yield the final_file:
>> >
>> > 1AKK  LYS     27      88      CA      3.7847    NZ    10.1088
>> > 1AKK  LYS     72      73      CA      3.8272    NZ    13.8547 
>> > 16.4(BS3) 1AKK  LYS     99      100     CA      3.8160    NZ   
>> > 10.6881  4.3(gsh) 
>> 
>> assuming enough ram is available to load both files into memory,
>> here's one way: 
> 
> [Snip Michael's fine answer]
> 
> Or if you don't want to slurp either file into ram, or want to have a
> method that will work for any number of fields, or one that will
> update multiple rows, or you want to include flock() protection, use
> AnyData. Here is a complete script to do what you want using the
> AnyData tied hash interface.  If you know SQL you could accomplish the
> same thing with DBD::AnyData using SQL.  Both are available on CPAN.

Here's another way. :-) It's similar to Michael's solution, but uses a 
hash instead of arrays. It's not as generalized as Jeff's, but it does use 
only one tied hash instead of two. (I used their solutions as inspiration)  
Note that the space in the hash key is essential for insuring a unique 
key.

use strict;
use warnings;
use Tie::Hash;
use DB_File;

my %data = ();
tie %data, "DB_File", 'data_hash', O_RDWR|O_CREAT, 0644;
open (DATAFILE, 'datafile') 
    or die ("Can't open datafile for reading: $!");
while ( <DATAFILE> ) {
    chomp;
    my @fields = (split /\s+/)[2,3];
    $data{ "$fields[0] $fields[1]" } = $_;
}
close DATAFILE;

open (INPUTFILE, 'input') or die ("Can't open input for reading: $!");
while ( <INPUTFILE> ) {
    my @fields = split /\s+/;
    $data{"$fields[0] $fields[1]"} .= " $fields[2]" 
        if exists $data{"$fields[0] $fields[1]"};
}
close INPUTFILE;

my $line;
print "$line\n" while (undef, $line) = each %data;
untie %data;

-- 
David Wall
darkon@one.net


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

Date: Thu, 04 Oct 2001 13:36:14 -0400
From: Glenn <glenn@surveystar.com>
Subject: Re: Can't unlink file under Perl for NT
Message-Id: <3BBC9E0E.B5A49AC9@surveystar.com>

As long as we're still asking questions, I still don't understand why
    $numdeleted=unlink "$somedir/file.*";
works under Unix without having to use glob() at all.


Bart Lateur wrote:

> Glenn wrote:
>
> >The following worked...
> >
> >    @list= glob ("e:/somedir/testfile.*");
> >    $numdeleted=unlink @list;
> >
> >Thanks to all for your help!
>
> and in another post:
>
> >>         $numdeleted = unlink glob('e:/somedir/testfile.*');
> >
> >Just tried that -- interesting result... each time I execute the script,
> >it deletes 1 file, until they're all gone.
>
> That is strange. If it is indeed the case, and why shouldn't it be  ;-),
> it looks to me as unlink() gives the wrong context to glob()? Because
> glob() in scalar context will return the path of the first matching
> file, and all of the matching files in list context. But then why does
> it work with an array?
>
> --
>         Bart.



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

Date: Thu, 4 Oct 2001 12:52:24 -0500
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: Can't unlink file under Perl for NT
Message-Id: <slrn9rp8eo.ejb.trammell@haqq.hypersloth.net>

On Thu, 04 Oct 2001 13:36:14 -0400, Glenn <glenn@surveystar.com> wrote:
["jeopardy" quote snipped -- please don't do that]
> 
> As long as we're still asking questions, I still don't understand why
>     $numdeleted=unlink "$somedir/file.*";
> works under Unix without having to use glob() at all.
>
>

Huh?

[ ~ ] touch foo
[ ~ ] perl -e 'unlink "f*"'
[ ~ ] ls f*
foo
[ ~ ]

-- 
Take LISP, make the syntax twice as annoying, and hey presto, XML!


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

Date: 4 Oct 2001 08:21:14 -0700
From: jennlee.2@eudoramail.com (Jennifer)
Subject: CGI form email oddness - not acting as expected
Message-Id: <e836199f.0110040721.17357526@posting.google.com>

Hi - 

I'm running Perl on a Novell web server and am using a program called
sendmail.pl (which I didn't write) to send web form content via email.
 It has been working but has some oddities I have not been able to
figure out or resolve.

When the email is received and viewed, the "To" field does not show up
as filled in.  The recipient email address shows up in the blind copy
spot, and the email ends up at the right place.  I've tested the
coding and it does in fact actually contain the TO field information,
outputing: "RCPT TO: address@something.wisc.edu".  If my understanding
is correct, this sould show up as "TO" in the email.

In addition, when I look at the email headers, I see a warning that
the HELO protocol was not used.  From the code it looks OK to me, but
maybe I'm missing something.

I'm hoping someone can give me some advice on why it is not acting as
expected.  Thanks much.  Code snippets below -

Jennifer


The snipped code that sends the header info is

  my($mailTo)     = "$body{recipient}";
  my($mailFrom)   = "$body{email}";
  my($realName)   = "$body{realname}";
  my($subject)    = "$body{subject}";

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

  socket(SMTP, AF_INET(), SOCK_STREAM(), $proto)
     or die("socket: $!");

  connect(SMTP, pack($packFormat, AF_INET(), $port, $serverAddr))
     or die("Connection to email server failed - contact the Support
Center or try again later: $!");

  select(SMTP); $| = 1; select(STDOUT);    # use unbuffered i/o.

  {
     my($inpBuf) = '';
     recv(SMTP, $inpBuf, 200, 0);
  }

  sendSMTP(1, "HELO\n");
  sendSMTP(1, "MAIL FROM: <$mailFrom>\n");
  sendSMTP(1, "RCPT TO: <$mailTo>\n");
  sendSMTP(1, "VRFY\n");
  sendSMTP(1, "DATA\n");

  sendSMTPnoresponse(1, "From: $realName <$mailFrom>\n");
  sendSMTPnoresponse(1, "Subject: $subject\n");
  sendSMTPnoresponse(1, "CC: $cc\n");
  sendSMTPnoresponse(1, "\n");


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

  sub sendSMTP {
    my ($debug) = shift;
    send_to_smtp($debug, 1, @_);
  }

  sub sendSMTPnoresponse {
    my ($debug) = shift;
    send_to_smtp($debug, 0, @_);
  }
-----------------------------------------------------------

The email headers show as (IP and DNS changed for posting):
Received: from webserver.something.wisc.edu
	(webserver.something.wisc.edu [99.9.99.999])
	by email.something.wisc.edu; Thu, 04 Oct 2001 08:45:20 -0500
X-Authentication-Warning: email.something.wisc.edu:
webserver.something.wisc.edu
	[99.9.99.999] didn't use HELO protocol
From:  jennifer@something.wisc.edu
Subject: Intranet Feedback
CC:


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

Date: 04 Oct 2001 13:08:42 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: CGI form email oddness - not acting as expected
Message-Id: <m38zerjpt1.fsf@mumonkan.sunstarsys.com>

jennlee.2@eudoramail.com (Jennifer) writes:

> When the email is received and viewed, the "To" field does not show up
> as filled in.  The recipient email address shows up in the blind copy
> spot, and the email ends up at the right place.  I've tested the
> coding and it does in fact actually contain the TO field information,
> outputing: "RCPT TO: address@something.wisc.edu".  If my understanding
> is correct, this sould show up as "TO" in the email.

<OT>
No.  When you use postal (snail) mail, there's an address on the envelope
and an address on the letter itself. For email, MTA's (like sendmail)
deal only with the info on the envelope, while MUA's (like eudora)
typically only look at the letter (the DATA).

Your script probably needs to add a "To:" header in the DATA portion. 
But why are you bypassing a local MSA and connecting directly to a mail 
server in the first place (which is causing your 
X-Authentication-Warnings)?  
</OT>


Have you considered using a module from CPAN, like say Mail::SendMail?  
Have you seen

  % perldoc -q "send mail"

?

-- 
Joe Schaefer     "Never put off until tomorrow that which can be done the day
                                       after tomorrow."
                                               --Mark Twain



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

Date: Thu, 4 Oct 2001 11:33:50 -0500
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: escape character for a space
Message-Id: <slrn9rp3re.dsm.trammell@haqq.hypersloth.net>

On Thu, 04 Oct 2001 09:54:38 -0400, Max Gravitt <magrav@wnt.sas.com> wrote:
> 
> I'm trying to use a space in the replacement string of a regular
> expression.  It is embedded in a batch file, so I can't pass a *real*
> space.  I can match a space using "\s", but I need a character that
> will insert a space at the specific place.
> 
> For example:
> s/Old\sString/New\sString/g
> 
> obviously does not work.  I need the equivalent to " " to insert in
> place of the "\s" between New and String.
> 
> Any ideas?
> 

s/Old\sString/New\ String/g
"s/Old\sString/New String/g"

-- 
[W]hen the manager knows his boss will accept status reports without
panic or preeemption, he comes to give honest appraisals.
                               - F. Brooks, _The Mythical Man-Month_


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

Date: 04 Oct 2001 18:24:55 +0100
From: nobull@mail.com
Subject: Re: escape character for a space
Message-Id: <u9ofnnxqqg.fsf@wcl-l.bham.ac.uk>

Max Gravitt <magrav@wnt.sas.com> writes:

> I'm trying to use a space in the replacement string of a regular
> expression.  It is embedded in a batch file, so I can't pass a *real*
> space.

\040

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Thu, 04 Oct 2001 16:08:25 +0100
From: "j.m.t.dowland" <j.m.t.dowland@durham.ac.uk>
To: gis88559@cis.nctu.edu.tw
Subject: Re: get "REMOTE_ADDR" with perl..
Message-Id: <3BBC7B69.A212BEB9@durham.ac.uk>

8823559 wrote:
> 
> Hi there,
> 
>    Can anyone of you help me with this problem?  Thanks a lot..:)
> 
>    It's O.K for me to get the environment variable "REMOTE_ADDR", while
> fail to get the "REMOTE_HOST".  I know some hosts turn off the feature
> for some speed concerns, the problem is, how should I turn it on again?
> 
>    I've also tried the perl built-in function "gethostbyaddr", but still
> in vain.  ($name = gethostbyaddr($IP, AF_INET))
> 
>    Could you please also reply it to my e-mail address?  Then I would be
> easier to see your great answers...:)
> 
>     My e-mail is:  gis88559@cis.nctu.edu.tw
> 
> --

at the top of your program, in the use declarations:
use Socket qw/AF_INET inet_aton/;

(or ignore the qw if you are using other features of the Socket library)

and:
$poster_host = gethostbyaddr(inet_aton($poster_ip), AF_INET);

puts the host of $poster_ip into $poster_host, assuming $poster_ip is a
valid ip. This works in the linux systems I've tried, and one sunOS one.


Basically you need to convert the IP into some format that I don't know
and the inet_aton function does that for you.


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

Date: Thu, 04 Oct 2001 17:19:28 +0200
From: Jean-Philippe Fauvelle <JPFauvelle@Colt-Telecom.fr>
Subject: Re: get "REMOTE_ADDR" with perl..
Message-Id: <p9uortk6ue20h49h395iqsbc4rvhf7voro@4ax.com>

Le Thu, 4 Oct 2001 13:22:59 +-0000 (UTC), 8823559
<gis88559@ultra2.cis.nctu.edu.tw> +AOk-crit:

>Hi there,
>
>   Can anyone of you help me with this problem?  Thanks a lot..:)
>
>   It's O.K for me to get the environment variable "REMOTE_ADDR", while
>fail to get the "REMOTE_HOST".  I know some hosts turn off the feature
>for some speed concerns, the problem is, how should I turn it on again?
>
>   I've also tried the perl built-in function "gethostbyaddr", but still
>in vain.  ($name = gethostbyaddr($IP, AF_INET))
>
>   Could you please also reply it to my e-mail address?  Then I would be
>easier to see your great answers...:)
>
>    My e-mail is:  gis88559@cis.nctu.edu.tw


use Socket qw/:DEFAULT/; # AF_INET

#...........................................................................................
# FQDN --> IPNB
#...........................................................................................
$fqdn= 'www.yahoo.com';
eval {
	local $SIG{'__DIE__'} = 'DEFAULT';
	local $SIG{'ALRM'} = sub {die "TIMEOUT+AFw-n"};
	alarm 3;
	$ipnb= inet_ntoa(scalar(gethostbyname($fqdn))) || '???';
	alarm 0;
};
print "$fqdn-> $ipnb+AFw-n"; # "www.yahoo.com -> 64.58.76.225"

#...........................................................................................
# IPNB -> FQDN
#...........................................................................................
$ipnb = '64.58.76.225';  # 'www.yahoo.com'
eval {
	local $SIG{'__DIE__'} = 'DEFAULT';
	local $SIG{'ALRM'} = sub {die "TIMEOUT+AFw-n"};
	alarm 3;
	$fqdn = lc gethostbyaddr( inet_aton($ipnb), AF_INET ) || '???';
	alarm 0;
};
print "$ipnb-> $fqdn+AFw-n";  # "64.58.76.225 -> www.yahoo.com"



Regards.

Jean-Philippe Fauvelle



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

Date: Thu, 4 Oct 2001 16:55:35 +0000 (UTC)
From: 8823559 <gis88559@ultra2.cis.nctu.edu.tw>
Subject: Re: get "REMOTE_ADDR" with perl..
Message-Id: <9pi4a6$1pvp$1@news.cis.nctu.edu.tw>

j.m.t.dowland <j.m.t.dowland@durham.ac.uk> ´£¨ì:
: at the top of your program, in the use declarations:
: use Socket qw/AF_INET inet_aton/;
: (or ignore the qw if you are using other features of the Socket library)
: and:
: $poster_host = gethostbyaddr(inet_aton($poster_ip), AF_INET);
: puts the host of $poster_ip into $poster_host, assuming $poster_ip is a
: valid ip. This works in the linux systems I've tried, and one sunOS one.
: Basically you need to convert the IP into some format that I don't know
: and the inet_aton function does that for you.

  It works fine now, thanks a lot for both replies...:)
-- 


-----------------------------------------------
Yi-Neng Lin(ªL¸q¯à)
High Speed Network lab  (NCTU: (03)5712121 ext:56667)
Department of Computer & Information Science
National Chiao Tong University
E-mail: gis90818@cis.nctu.edu.tw
Homepage: http://www.cis.nctu.edu.tw/~gis90818
-----------------------------------------------


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

Date: 04 Oct 2001 18:23:47 +0100
From: nobull@mail.com
To: gis88559@cis.nctu.edu.tw
Subject: Re: get "REMOTE_ADDR" with perl..
Message-Id: <u9u1xfxqsc.fsf@wcl-l.bham.ac.uk>

8823559 <gis88559@ultra2.cis.nctu.edu.tw> writes:

>    It's O.K for me to get the environment variable "REMOTE_ADDR", while
> fail to get the "REMOTE_HOST".  I know some hosts turn off the feature
> for some speed concerns, the problem is, how should I turn it on again?

See manuals for your web server.  If that doesn't help try asking in a
newsgroup that deals with web server configuration.

>    I've also tried the perl built-in function "gethostbyaddr", but still
> in vain.  ($name = gethostbyaddr($IP, AF_INET))

See "perldoc -f gethostbyaddr" for an example of correct usage of the
gethostbyaddr() function.  Note that $IP must be a packed address not
a string.  If you still have problems plase post a short but complete
script that you believe should convert a string representation of a
numeric IP address to a DNS name and expalin how it fails.
 
>    Could you please also reply it to my e-mail address?  Then I would be
> easier to see your great answers...:)

Please use a "Mail-copies-to" header rather than asking people to
transcribe your address by hand.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Thu, 04 Oct 2001 17:23:40 -0000
From: David Wall <darkon@one.net>
Subject: Re: Help
Message-Id: <Xns9130882B4FC8Edarkononenet@207.126.101.97>

"Jonathan Clover" <jclover@nati.org> wrote on 03 Oct 2001:

> tend to use an computer using the $top{"OS} Operating System, while

$top{"OS} should be $top{"OS"}

> often with $top{"Browser"}.  THey tended to access the course most often

It's not a problem, but don't you mean 'They', not 'THey'? :-)

> 1258:      <td valign="top">";

You don't need the ";    Looks like it was left over from a previous edit.

-- 
David Wall
darkon@one.net


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

Date: Thu, 04 Oct 2001 16:27:02 GMT
From: "John Beavers" <john@tesserv.com>
Subject: How do I get byte count of retreived site using LWP::UserAgent
Message-Id: <q50v7.755$s62.300445718@newssvr12.news.prodigy.com>

I have a script were I check links within a site. I am not sure how to get
the byte count of the link that was retrived. Can someone please help?
Thanks.






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

Date: 4 Oct 2001 10:11:01 -0700
From: sumera.shaozab@lmco.com (SAS)
Subject: How to manipulate data from database
Message-Id: <a741872d.0110040911.202b07f3@posting.google.com>

Hi,

I am using Perl DBI to extract data from oracle and then put the data
in xml format. I am joining all of the tables to get the result, so I
only execute one sql select statement.  This is the format I recieve
in:

Fname,Lname,SSID,p_num,T1,T2,T3,address1,address2,city,state,e_num

The problem is that I have alot of 1 to many results.  That is for
each Fname,Lname, I could get up to 1000 p_num. So each result
recieved will have Fname,Lname,SSID,T1,T2,T3 repeated up to 1000 times
and the p_num ofcourse is different.  So in my while statement, I am
taking each result returned from the database and put it in xml
format...but I get alot of repeated fields. How do I manipulate the
data so that I don't include the repeated fields in my xml document?

TIA

SAS


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

Date: Wed, 3 Oct 2001 13:23:49 -0500
From: "T.H." <tambaa@no.spam.yahoo.com>
Subject: Need help to suppress STDOUT
Message-Id: <9phvou$86$1@tilde.csc.ti.com>

Hi all,

I am calling a an external program using system from within a perl script. I
am trying to redirect (using >) the output to file but the program output is
still being displayed on the screen. I tried closing STDOUT before using
system just to see whether that would make a difference but it doesn't.

Anyone know how I can completely suppress the output to the screen?

Thanks in advance,
TH
--
 .




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

Date: Thu, 04 Oct 2001 10:46:44 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Need help to suppress STDOUT
Message-Id: <87y9mr76hn.fsf@limey.hpcc.uh.edu>

>> On Wed, 3 Oct 2001 13:23:49 -0500,
>> "T.H." <tambaa@no.spam.yahoo.com> said:

> Hi all, I am calling a an external program using system
> from within a perl script. I am trying to redirect
> (using >) the output to file but the program output is
> still being displayed on the screen. I tried closing
> STDOUT before using system just to see whether that
> would make a difference but it doesn't.

> Anyone know how I can completely suppress the output to
> the screen?

It's probably writing to stderr.  Close that too, or
(easier) redirect to /dev/null in the system() call.  (It
might be opening the tty directly though.)

hth
t
-- 
Whoops, I've said too much.  Smithers, use the amnesia ray...


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

Date: Thu, 4 Oct 2001 11:37:41 -0500
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: Need help to suppress STDOUT
Message-Id: <slrn9rp42l.dsm.trammell@haqq.hypersloth.net>

On Wed, 3 Oct 2001 13:23:49 -0500, T.H. <tambaa@no.spam.yahoo.com> wrote:
> I am calling a an external program using system from within a perl script. I
> am trying to redirect (using >) the output to file but the program output is
> still being displayed on the screen. I tried closing STDOUT before using
> system just to see whether that would make a difference but it doesn't.
> 
> Anyone know how I can completely suppress the output to the screen?
> 

Please show your code and tell what OS you're using.

But something like system("/bin/foo 1>stdout.txt 2>stderr.txt") has
always worked for me.

-- 
I don't know what the hell is going on dude, but this suspension gives
me more time for fraggin'.  Yee haw!


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

Date: Thu, 4 Oct 2001 11:37:51 -0500
From: "T.H." <tambaa@no.spam.yahoo.com>
Subject: Re: Need help to suppress STDOUT
Message-Id: <9pi2so$7al$1@tilde.csc.ti.com>

"Tony Curtis" <tony_curtis32@yahoo.com> wrote in message
news:87y9mr76hn.fsf@limey.hpcc.uh.edu...
> >> On Wed, 3 Oct 2001 13:23:49 -0500,
> >> "T.H." <tambaa@no.spam.yahoo.com> said:
>
> > Hi all, I am calling a an external program using system
> > from within a perl script. I am trying to redirect
> > (using >) the output to file but the program output is
> > still being displayed on the screen. I tried closing
> > STDOUT before using system just to see whether that
> > would make a difference but it doesn't.
>
> > Anyone know how I can completely suppress the output to
> > the screen?
>
> It's probably writing to stderr.  Close that too, or
> (easier) redirect to /dev/null in the system() call.  (It
> might be opening the tty directly though.)

I believe that the external program may be opening tty directly. If that's
the case, is there a way to suppress the output temporarily?




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

Date: 4 Oct 2001 09:33:41 -0700
From: dboyce@phoenixcolor.com (Dan Boyce)
Subject: Re: Perl Guru needed for this extremely frustrating search and replace problem.
Message-Id: <3fac67fd.0110040833.5550646a@posting.google.com>

Thanks for the help, but still no luck.  I tried your line as is, and
it just deleted INSTALL_DIR and put nothing in its place.  I tried
modifying it a bit and again no luck.
If anyone out there know how to fix this could they please enlighten
me?
Thanks in advance,
Dan

Michael Budash <mbudash@sonic.net> wrote in message news:<mbudash-A0C5AE.14215903102001@news.sonic.net>...
> In article <3fac67fd.0110031258.3cce7cd8@posting.google.com>, 
> dboyce@phoenixcolor.com (Dan Boyce) wrote:
> 
> > Perl version - v5.6.0 built for i386-linux 
> > 
> > Some how I need to convert the script below to allow me to enter a
> > directory structure (ie. /home/dan/).  Using a script that I have
> > found in a book I can replace INSTALL_DIR with strings as long as they
> > do not contain "/" in them.
> > 
> > 
> > 
> > [root@localhost setup]# ./test
> > Replace with:
> > 
> > /home/dan/program/
> > Bareword found where operator expected at -e line 1, near
> > "s/INSTALL_DIR//home"
> > syntax error at -e line 1, near "s/INSTALL_DIR//home"
> > Search pattern not terminated at -e line 1.
> > test.conf
> > INSTALL_DIR/conf/config.cfg
> > [root@localhost setup]#
> > 
> > The following is the test script:
> > #/bin/sh
> > echo "Replace with: "
> > read number_two
> > cp test.conf test.conf.bak
> > perl -p -i -e s/INSTALL_DIR/$number_two/ test.conf
> > echo "test.conf"
> > more test.conf
> > 
> > 
> > For testing purposes my test.conf file contains the following:
> > INSTALL_DIR/conf/config.cfg 
> > 
> > 
> > Is this possible to do, if not would anyone be kind enough to help me
> > write a new one?
> > 
> > Thanks,
> > Dan
> 
> try this (untested) replacement line in the test script:
> 
> perl -p -i -e 's{INSTALL_DIR}{$number_two}' test.conf
>  
> hth-


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

Date: Thu, 04 Oct 2001 16:57:31 GMT
From: "Jessica Bull" <jessica.bull@broadwing.com>
Subject: Permission Denied Errors
Message-Id: <%x0v7.101687$hh.9075455@bin1.nnrp.aus1.giganews.com>

I am trying to read directories or files.  I am not able to do this as the
system sends back a message:  Permission Denied.  I am on Windows NT.  I
thought that the OS credentials would be used to determine the permissions.
I have tried two ways to access it.  Set the variable to the drive letter
that is mapped and to just enter the full path name.  Both return the same
message, though from the desktop the script is running, the permissions are
fine.  Has anyone experienced this before?  I can't seem to find any info on
this and I have never seen this before.  Help if you can.  Thanks.

Jess

Here is an a piece of the code.  This is in an eval statement to catch the
die code.  That is how I know that it is a permissions denied error.

my $chkdir = "\\\\ixcnt02\\nt02_v\\j\\iol\\r224\\response";
open (DIR, "$chkdir") or die "Can not open the specified directory: $chkdir
: $! \n";

Here is the error:

2001.10.04.09.48.18
Fatal Errors : Can not open the specified directory:
\\ixcnt02\nt02_v\j\iol\r224\response : Permission denied
Mail Errors: 1
End Errors







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

Date: Thu, 04 Oct 2001 10:09:20 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Permission Denied Errors
Message-Id: <3BBC97C0.2C61B93A@vpservices.com>

Jessica Bull wrote:
> 
> my $chkdir = "\\\\ixcnt02\\nt02_v\\j\\iol\\r224\\response";

That's awfuly hard to read.  Perl understands forward slashes as
directory separators even on windoze so rewrite that as:

   my $chkdir = '/ixcnt02/nt02_v/j/iol/r224/response';


> open (DIR, "$chkdir") or die "Can not open the specified directory: $chkdir
> : $! \n";

The function open() applies to files.  The function opendir() applies to
directories.

-- 
Jeff



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

Date: Thu, 4 Oct 2001 18:12:42 +0100
From: "S Warhurst" <s.warhurst@rl.ac.uk>
Subject: Re: Permission Denied Errors
Message-Id: <9pi5aa$1ahk@newton.cc.rl.ac.uk>

I know it might be an obvious question but can you access that share (via
network neighbourhood) from the NT machine running the Perl script? It does
sound like an NT permissions issue.

---------¦
  Bigus @ work
             ¦----------


"Jessica Bull" <jessica.bull@broadwing.com> wrote in message
news:%x0v7.101687$hh.9075455@bin1.nnrp.aus1.giganews.com...
> I am trying to read directories or files.  I am not able to do this as the
> system sends back a message:  Permission Denied.  I am on Windows NT.  I
> thought that the OS credentials would be used to determine the
permissions.
> I have tried two ways to access it.  Set the variable to the drive letter
> that is mapped and to just enter the full path name.  Both return the same
> message, though from the desktop the script is running, the permissions
are
> fine.  Has anyone experienced this before?  I can't seem to find any info
on
> this and I have never seen this before.  Help if you can.  Thanks.
>
> Jess
>
> Here is an a piece of the code.  This is in an eval statement to catch the
> die code.  That is how I know that it is a permissions denied error.
>
> my $chkdir = "\\\\ixcnt02\\nt02_v\\j\\iol\\r224\\response";
> open (DIR, "$chkdir") or die "Can not open the specified directory:
$chkdir
> : $! \n";
>
> Here is the error:
>
> 2001.10.04.09.48.18
> Fatal Errors : Can not open the specified directory:
> \\ixcnt02\nt02_v\j\iol\r224\response : Permission denied
> Mail Errors: 1
> End Errors
>
>
>
>
>




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

Date: Thu, 04 Oct 2001 19:58:58 +0200
From: Thomas Bätzler <thomas@baetzler.de>
Subject: Re: Permission Denied Errors
Message-Id: <lt7prts1lo5eol2ho6gcifsam22mv3rqe5@4ax.com>

On Thu, 04 Oct 2001, Jeff Zucker <jeff@vpservices.com> wrote:

>Jessica Bull wrote:
>> 
>> my $chkdir = "\\\\ixcnt02\\nt02_v\\j\\iol\\r224\\response";

>That's awfuly hard to read.  Perl understands forward slashes as
>directory separators even on windoze so rewrite that as:
>
>   my $chkdir = '/ixcnt02/nt02_v/j/iol/r224/response';

This should read

 my $chkdir = '//ixcnt02/nt02_v/j/iol/r224/response';

as the double (back)slash is there to identify this as an SBM server
name. 

As to the other problem - if it isn't a bug in the code, as the
snippet would suggest, there could be another explanation: code that
runs under the system account (i.e. from a scheduler) does not have
access to network shares. And of course drive mappings only apply to
the account that's currently logged in.

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: 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 1871
***************************************


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