Re: How do I use grep to get a list of files given multiple grep criteria?

2002-05-26 Thread John W. Krahn

Robert Btb Tky Schuessler wrote:
> 
> Hello,

Hello,

> I want to use grep to get a list of files into @files.  Here's what it looks
> like now:
> 
> $sender = "CHAS";
> $asofdate = "20020401";
> 
> @files = `grep -sl $sender /home/data/*`;
> print @files;
> 
> This gets all the files that contain CHAS, but what I really want is all the
> files that contain CHAS and $asofdate and SETTLED.
> 
> These unix commands work to get the correct subset of files (I'm using ksh):
> 
> grep -sl \SETTLED\<\/basis\> $( grep -l CHAS $(grep -l
> \20020401\<\/asOfDate\> /home/data/*))
> grep -sl $bic /home/data/* | xargs grep -l \SETTLED\<\/basis\> |
> xargs grep -l \$asofdate\<\/asOfDate\>
> 
> If I try the first of these between the backticks in the perl script, I get
> a sh error because it doesn't understand the ksh $() syntax.
> If I try the second, I get this error:
> sh: syntax error at line 1: `|' unexpected
> 
> Can somebody suggest an easy way to call either of the above commands or to
> emulate them with a perl command?  (For the moment, I've put them into a ksh
> script and am calling the script, but I would like the perl script to be
> self-contained.)

Once you get the list of files do you want to modify their contents? 
Delete them?  Copy or move them to a different location?

If you just want to print out the list of files (all on one line):

perl
-lne'print($ARGV)&&close(ARGV)if/SETTLED<\/basis>/&&/CHAS/&&/20020401<\/asOfDate>/'
/home/data/*



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




POP3 mail and Attachment

2002-05-26 Thread Shibu

Can anybody help me in writing a script in getting a email with
attachment saved into some folder / directory. I have already written a
script to receive email but the body are mime encoded. I want to get
email with attachment saved in separate folder.




Shibu
Phone:5341669 Ext:400 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How do I use grep to get a list of files given multiple grep criteria?

2002-05-26 Thread bob ackerman


On Sunday, May 26, 2002, at 09:53  PM, Schuessler, Robert BTB TKY wrote:

> Hello,
>
> I want to use grep to get a list of files into @files.  Here's what it 
> looks
> like now:
>
> $sender = "CHAS";
> $asofdate = "20020401";
>
> @files = `grep -sl $sender /home/data/*`;
> print @files;
>
>
>
> This gets all the files that contain CHAS, but what I really want is all 
> the
> files that contain CHAS and $asofdate and SETTLED.
>
> These unix commands work to get the correct subset of files (I'm using 
> ksh):
>
> grep -sl \SETTLED\<\/basis\> $( grep -l CHAS $(grep -l
> \20020401\<\/asOfDate\> /home/data/*))
> grep -sl $bic /home/data/* | xargs grep -l \SETTLED\<\/basis\> |
> xargs grep -l \$asofdate\<\/asOfDate\>
>
>
> If I try the first of these between the backticks in the perl script, I 
> get
> a sh error because it doesn't understand the ksh $() syntax.

i am not sure, but i would guess you have to escape the $ if you want it 
to go the shell without perl trying to interpolate it.

> If I try the second, I get this error:
> sh: syntax error at line 1: `|' unexpected

same with the pipe thingie.

>
> Can somebody suggest an easy way to call either of the above commands or 
> to
> emulate them with a perl command?  (For the moment, I've put them into a 
> ksh
> script and am calling the script, but I would like the perl script to be
> self-contained.)
>
>
> Thanks for your advice,
> Robert
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




How do I use grep to get a list of files given multiple grep criteria?

2002-05-26 Thread Schuessler, Robert BTB TKY

Hello,

I want to use grep to get a list of files into @files.  Here's what it looks
like now:

$sender = "CHAS";
$asofdate = "20020401";

@files = `grep -sl $sender /home/data/*`;
print @files;



This gets all the files that contain CHAS, but what I really want is all the
files that contain CHAS and $asofdate and SETTLED.

These unix commands work to get the correct subset of files (I'm using ksh):

grep -sl \SETTLED\<\/basis\> $( grep -l CHAS $(grep -l
\20020401\<\/asOfDate\> /home/data/*))
grep -sl $bic /home/data/* | xargs grep -l \SETTLED\<\/basis\> |
xargs grep -l \$asofdate\<\/asOfDate\>


If I try the first of these between the backticks in the perl script, I get
a sh error because it doesn't understand the ksh $() syntax.
If I try the second, I get this error:
sh: syntax error at line 1: `|' unexpected

Can somebody suggest an easy way to call either of the above commands or to
emulate them with a perl command?  (For the moment, I've put them into a ksh
script and am calling the script, but I would like the perl script to be
self-contained.)


Thanks for your advice,
Robert


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




cgi script that takes in data then runs script on different host

2002-05-26 Thread Simon K. Chan

Hi All,

I've got a cgi form that takes in data.  Then, I want the data to be passed to a 
script that's
waiting on a DIFFERENT host.

So, say I have this pseudo-code:

cgi script on host 1pass $name to host 2  script on host 2
# get $name --->  print "hi there $name!\n";

Obviously, I'll be doing something a little more in-depth than printing the variables, 
but you get
the idea!


I went through perlfaq 8 in the perldocs, but I didn't understand the networking 
jargon :-(

Thanks!
Simon

=
#

Warmest Regards,
Simon K. Chan - [EMAIL PROTECTED]

"Great spirits have always encountered violent opposition from mediocre minds."  - 
Albert Einstein

__
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: complementing a scalar

2002-05-26 Thread mark


"This means: Take all the characters *not* in the SEARCHLIST and look
for those."

In my case, sometimes the shortest distance between 2 points is a circle.
It finally sank in sometime yesterday and in celebration I spent the entire
evening and most of the night pouring over perldoc.  My problem was the
definition of  "complement" as Perl understood it.

Thanks for your help.
Mark




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: ActivePerl problem

2002-05-26 Thread mark


> It has always just worked for me...  when you drop to a cmd prompt and
> type 'path' what do you get?  here is what mine looks like
> PATH=D:\Perl\bin\;C:\WINNT\system32;C:\WINNT;...
> that part for \perl\bin is what you are looking for.  When you edited
> it (as you say above) where did you edit it?  To edit it system wide
> (which is what you want) you need to get properties on 'My Computer',
> go to the 'Advanced' tab, select the Env Vars button.  The bottom half
> is where you want to add your c:\perl\bin;.
> 
> -- 
> [EMAIL PROTECTED]


That is where I changed it.

I get :  PATH=C:\WINNT\system32;C:\WINNT;C:\W...
but no Perl\bin\;

Mark


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: complementing a scalar

2002-05-26 Thread Elias Assmann

On Sat, 25 May 2002, mark wrote:

> What is happening here exactly and what precisely does the /c do in this
> statement?  I've had a couple of answers that I do not understand and thus
> far I've been told that /c "complements" the SearchPattern.  OK

I'm sorry that my original reply didn't help you. Let me try once
more. You know, I don't mean to sound rude, but I get the feeling that
you're making a similar kind of mistake as I often do when asking such
questions: Trying to clever, and making guesses at what the answer
will be, which then keeps you from understanding it.

If I'm right, try to step back a bit and get a new perspective. If
not, well, never mind me.

> So my question is (drumroll) : Do I take it to mean that /c also adds the
> negative values of the given SearchPattern to the SearchPattern?  Otherwise,
> what is the "complement of /a-z/ if not /-(a-z)/ ?

I think you have it almost right actually, only thing is, I don't
quite understand you...

Hum, what does perldoc say to this? perldoc perlop says:

   tr/SEARCHLIST/REPLACEMENTLIST/cdsUC

   y/SEARCHLIST/REPLACEMENTLIST/cdsUC
   Transliterates all occurrences of the characters
   found in the search list with the corresponding
   character in the replacement list.

Okay, I think you're with me thus far :-)

It gets more interesting here:

   Options:
   c   Complement the SEARCHLIST.
   d   Delete found but unreplaced characters.

   yada yada...

   If the `/c' modifier is specified, the SEARCHLIST
   character set is complemented.

This means: Take all the characters *not* in the SEARCHLIST and look
for those.

   If the `/d' modi­
   fier is specified, any characters specified by
   SEARCHLIST not found in REPLACEMENTLIST are
   deleted.

So, delete everything we don't have a replacement for. Do you
understand these two concepts now? If not, try typing this in your
favorite shell:

perl -ple'tr/abc//d'

Play around a bit with it, give it a few lines to process and see what
comes out... Then this:

perl -ple'tr/abc//cd'

Note the difference...

Now, let's have another look at your original line:

$name =~ tr/a-zA-Z0-9-_ .,:;'&$#@!*()?-//cd;

The searchlist here is "a-zA-Z0-9-_ .,:;'&$#@!*()?-", the replacement
list is "". Then /c comes along and complements the searchlist, so
that now all characters not in the set "a-zA-Z0-9-_ .,:;'&$#@!*()?-"
are looked for.

Since there we have REPLACEMENTLIST (or else it's empty), we can't
replace anything, but /d tells us to delete all the characters we
cannot replace, so what do we do? Delete all the (matching) characters
we find.

In effect: look for all characters not in "a-zA-Z0-9-_.,:;'&$#@!*()?-"
and delete them.

I hope this reply is more useful than my last.

Elias

-- 
Gefängnis für Hans Mustermann wegen
Fälschung und Verrat

 -- Die Einstürzenden Neubauten, Was ist ist



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: ActivePerl problem

2002-05-26 Thread Tim Musson

Hey mark,

My MUA believes you used Microsoft Outlook Express 5.50.4522.1200
to write the following on Sunday, May 26, 2002 at 12:47:39 AM.

m> Hi,

m> I can't seem to get ActivePerl working on my win2k machine.

m> I checked my enviroment variables and found it not there.  I edited my ev's
m> to include Perl:
m> C:\Perl\bin and tried C:\Perl\bin\perl.exe;

m> I tried it both as User and as Admin.

m> I tried perl -v to test it out in both cases and got:

m> 'perl' is not recognized as an internal or external command, operable
m> program or batch file.

m> But if I cd\Perl\bin and then type perl -v at the prompt while in that dir
m> it works.

m> What else do I have to do to get it working properly?  It would be nice to
m> be able to test scripts and stuff without having to cd\ into the proper
m> directory.  Who knows what other trouble I could cause myself once I
m> actually get it working.

It has always just worked for me...  when you drop to a cmd prompt and
type 'path' what do you get?  here is what mine looks like
PATH=D:\Perl\bin\;C:\WINNT\system32;C:\WINNT;...
that part for \perl\bin is what you are looking for.  When you edited
it (as you say above) where did you edit it?  To edit it system wide
(which is what you want) you need to get properties on 'My Computer',
go to the 'Advanced' tab, select the Env Vars button.  The bottom half
is where you want to add your c:\perl\bin;.

-- 
[EMAIL PROTECTED]
MUA = TB! v1.60k (www.RitLabs.com/The_Bat)
Windows 2000 5.0.2195 (Service Pack 2)
The days of the digital watch are numbered.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: ActivePerl problem

2002-05-26 Thread mark

Hi Leila,

I am using win2000 and the page you provided a link to says that I don't
need any other stuff.

Actually, it seemed to have installed fine for me as well.  I just have to
cd\ into Perl\bin in order to use it.

I took a peek a ActiveState's user forum to see if I could get some advice,
but it really doesn't seem VeryActive.

Thanks,
Mark



- Original Message -
From: "Leila Lappin" <[EMAIL PROTECTED]>
To: "mark" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Sunday, May 26, 2002 4:01 PM
Subject: Re: ActivePerl problem


> Hi Mark,
>
> I downloaded ActivePerl yesterday and it seems to work, though I haven't
> tested any scripts with it yet.  I thought it might help to check what was
> downloaded.  I downloaded my copy from
> http://www.activestate.com/Products/Download/Get.plex?id=ActivePerl&a=e
> After reading the documentation I downloaded InstMsi.exe first  and then
> ActivePerl-5.6.1.631-MSWin32-x86.msi after that.
>
> - Original Message -
> From: "mark" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Saturday, May 25, 2002 9:47 PM
> Subject: ActivePerl problem
>
>
> > Hi,
> >
> > I can't seem to get ActivePerl working on my win2k machine.
> >
> > I checked my enviroment variables and found it not there.  I edited my
> ev's
> > to include Perl:
> > C:\Perl\bin and tried C:\Perl\bin\perl.exe;
> >
> > I tried it both as User and as Admin.
> >
> > I tried perl -v to test it out in both cases and got:
> >
> > 'perl' is not recognized as an internal or external command, operable
> > program or batch file.
> >
> > But if I cd\Perl\bin and then type perl -v at the prompt while in that
dir
> > it works.
> >
> > What else do I have to do to get it working properly?  It would be nice
to
> > be able to test scripts and stuff without having to cd\ into the proper
> > directory.  Who knows what other trouble I could cause myself once I
> > actually get it working.
> >
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: ActivePerl problem

2002-05-26 Thread Leila Lappin

Hi Mark,

I downloaded ActivePerl yesterday and it seems to work, though I haven't
tested any scripts with it yet.  I thought it might help to check what was
downloaded.  I downloaded my copy from
http://www.activestate.com/Products/Download/Get.plex?id=ActivePerl&a=e
After reading the documentation I downloaded InstMsi.exe first  and then
ActivePerl-5.6.1.631-MSWin32-x86.msi after that.

- Original Message -
From: "mark" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, May 25, 2002 9:47 PM
Subject: ActivePerl problem


> Hi,
>
> I can't seem to get ActivePerl working on my win2k machine.
>
> I checked my enviroment variables and found it not there.  I edited my
ev's
> to include Perl:
> C:\Perl\bin and tried C:\Perl\bin\perl.exe;
>
> I tried it both as User and as Admin.
>
> I tried perl -v to test it out in both cases and got:
>
> 'perl' is not recognized as an internal or external command, operable
> program or batch file.
>
> But if I cd\Perl\bin and then type perl -v at the prompt while in that dir
> it works.
>
> What else do I have to do to get it working properly?  It would be nice to
> be able to test scripts and stuff without having to cd\ into the proper
> directory.  Who knows what other trouble I could cause myself once I
> actually get it working.
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]