- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: search pattern issue
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-24-2010 12:26 AM
тАО09-24-2010 12:26 AM
Re: search pattern issue
only the first pattern working, others not working, problem is why perl picks up all pattern they are not even on the $pattern values ?
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-24-2010 12:35 AM
тАО09-24-2010 12:35 AM
Re: search pattern issue
Thanks, the problem solved apparently now, but another problem ,if patterns don t match , still written into OUTPUT file ??
is it weird ? something is missing in the loop ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-24-2010 12:42 AM
тАО09-24-2010 12:42 AM
Re: search pattern issue
What exactly do you get in the output file in this case?
Horia.
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-24-2010 12:45 AM
тАО09-24-2010 12:45 AM
Re: search pattern issue
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-24-2010 12:48 AM
тАО09-24-2010 12:48 AM
Re: search pattern issue
@users=`cat /etc/passwd|awk -F: '{print \$1}'`;
my $K;
open(OUT,">>/tmp/LogonOutput");
for ( $K = 1; $K <= @users; $K++ )
{
open(IN,"/tmp/UserLogin");
while ($line=
{
$pattern = "$users[$K-1]" ;
if ( $line =~ m/$pattern{0}/ ) {
print "$pattern equal to $line\n";
print OUT "$line\n";
}
}
close(IN);
}
close(OUT);
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-24-2010 01:08 AM
тАО09-24-2010 01:08 AM
Re: search pattern issue
What exactly do you get in the output file in this case?
this is from output file:
LOGIN Sep 17 2010 18:03:09
root Sep 17 2010 18:03:24
student Sep 20 2010 13:55:45
LOGIN and root are not in the @users list but goes to output file ??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-24-2010 01:14 AM
тАО09-24-2010 01:14 AM
Re: search pattern issue
I tried to change environment and seems its working now , so my test server has some problems by Perl sources ??
I will notify the solution after completed tests.
Thanks
Hakki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-24-2010 01:17 AM
тАО09-24-2010 01:17 AM
SolutionThis could be true also for the "student" user.
Looks strange the presence of LOGIN.
grep LOGIN /etc/passwd?
Can you attach the file /tmp/UserLogin ?
Horia.
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-24-2010 01:19 AM
тАО09-24-2010 01:19 AM
Re: search pattern issue
What exactly did you changed in the env. ?
Horia.
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-24-2010 02:34 AM
тАО09-24-2010 02:34 AM
Re: search pattern issue
No, I took it out from passwd file with "grep -v"
I meant another server with environment change.
Last script is here (working great now!)
@users=`cat /etc/passwd|awk -F: '{print \$1}'|grep -vE 'root|nwauto|daemon|bin|sys|adm|uucp|lp|www|webadmi
n|hpdb|informix|nuucp|smbnull|mysql|nwcron|goglobal|alop|trop|dbadmin|c7op|sysadmin`;
my $K;
open(OUT,">>/tmp/LogonOutput");
for ( $K = 1; $K <= @users; $K++ )
{
open(IN,"/tmp/UserLogin");
while ($line=
{
$pattern = "$users[$K-1]" ;
if ( $line =~ m/\b$pattern{0}/ ) {
print "$pattern equal to $line\n";
print OUT "$line";
}
}
close(IN);
}
close(OUT);