- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Perl and find command
Operating System - HP-UX
1820879
Members
5149
Online
109628
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
тАО07-14-2009 07:58 AM
тАО07-14-2009 07:58 AM
Hello,
I am using find2perl for finding files with no UIDs.
#! /usr/opt/perl5/bin/perl -w
eval 'exec /usr/opt/perl5/bin/perl -S $0 ${1+"$@"}'
if 0; #$running_under_some_shell
use strict;
use File::Find ();
# Set the variable $File::Find::dont_use_nlink if you're using AFS,
# since AFS cheats.
# for the convenience of &wanted calls, including -eval statements:
use vars qw/*name *dir *prune/;
*name = *File::Find::name;
*dir = *File::Find::dir;
*prune = *File::Find::prune;
sub wanted;
my (%uid, %user);
while (my ($name, $pw, $uid) = getpwent) {
$uid{$name} = $uid{$uid} = $uid;
}
# Traverse desired filesystems
File::Find::find({wanted => \&wanted}, '/');
exit;
sub wanted {
my ($dev,$ino,$mode,$nlink,$uid,$gid);
(
(($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
($dev >= 0)
||
($dev >= 0)
) &&
!exists $uid{$uid} &&
print("$name\n");
}
Can someone help in fixing the following errors.
Use of uninitialized value in numeric ge (>=) at ./find_owner_script.pl line 35.
Use of uninitialized value in exists at ./find_owner_script.pl line 35.
Also I would like to exclude proc from the search.
Thanks.
I am using find2perl for finding files with no UIDs.
#! /usr/opt/perl5/bin/perl -w
eval 'exec /usr/opt/perl5/bin/perl -S $0 ${1+"$@"}'
if 0; #$running_under_some_shell
use strict;
use File::Find ();
# Set the variable $File::Find::dont_use_nlink if you're using AFS,
# since AFS cheats.
# for the convenience of &wanted calls, including -eval statements:
use vars qw/*name *dir *prune/;
*name = *File::Find::name;
*dir = *File::Find::dir;
*prune = *File::Find::prune;
sub wanted;
my (%uid, %user);
while (my ($name, $pw, $uid) = getpwent) {
$uid{$name} = $uid{$uid} = $uid;
}
# Traverse desired filesystems
File::Find::find({wanted => \&wanted}, '/');
exit;
sub wanted {
my ($dev,$ino,$mode,$nlink,$uid,$gid);
(
(($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
($dev >= 0)
||
($dev >= 0)
) &&
!exists $uid{$uid} &&
print("$name\n");
}
Can someone help in fixing the following errors.
Use of uninitialized value in numeric ge (>=) at ./find_owner_script.pl line 35.
Use of uninitialized value in exists at ./find_owner_script.pl line 35.
Also I would like to exclude proc from the search.
Thanks.
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-14-2009 08:14 AM
тАО07-14-2009 08:14 AM
Re: Perl and find command
Hi Robert:
Why are you adding Perl to what you can't do in a shell?
You closed this thread without evaluatiing or commenting on much of the information you were provided:
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1355210
Perl's 'find2perl' is designed to be a helper agent to translate shell 'find()' syntax into Perl.
That said, you could do this in the shell as:
# find /path -xdev -type f -nouser
Regards!
...JRF...
Why are you adding Perl to what you can't do in a shell?
You closed this thread without evaluatiing or commenting on much of the information you were provided:
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1355210
Perl's 'find2perl' is designed to be a helper agent to translate shell 'find()' syntax into Perl.
That said, you could do this in the shell as:
# find /path -xdev -type f -nouser
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-14-2009 09:22 AM
тАО07-14-2009 09:22 AM
Re: Perl and find command
I am using perl to expedite the find command. I know it can be done using shell and I am trying to use perl to compare each of them.
Thanks.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-14-2009 10:32 AM
тАО07-14-2009 10:32 AM
Solution
Hi (again) Robert:
> I am using perl to expedite the find command. I know it can be done using shell and I am trying to use perl to compare each of them.
OK, then here's a cleaned up variation of what you posted:
# cat ./findnousers
#!/usr/bin/perl
use strict;
use warnings;
use File::Find ();
my @path = @ARGV ? @ARGV : ('.');
my ( %uid, $name, $pw, $uid );
sub wanted {
my ( $dev, $ino, $mode, $nlink, $uid, $gid );
( ( $dev, $ino, $mode, $nlink, $uid, $gid ) = lstat($_) )
&& !exists $uid{$uid}
and print "$File::Find::name\n";
}
while ( ( $name, $pw, $uid ) = getpwent ) {
$uid{$uid}++;
}
File::Find::find( { wanted => \&wanted }, @path );
exit;
...
You can run passing zero or more path arguments. If no arguments are given then the current working directory is assumed.
# ./findnousers /home
Regards!
...JRF...
> I am using perl to expedite the find command. I know it can be done using shell and I am trying to use perl to compare each of them.
OK, then here's a cleaned up variation of what you posted:
# cat ./findnousers
#!/usr/bin/perl
use strict;
use warnings;
use File::Find ();
my @path = @ARGV ? @ARGV : ('.');
my ( %uid, $name, $pw, $uid );
sub wanted {
my ( $dev, $ino, $mode, $nlink, $uid, $gid );
( ( $dev, $ino, $mode, $nlink, $uid, $gid ) = lstat($_) )
&& !exists $uid{$uid}
and print "$File::Find::name\n";
}
while ( ( $name, $pw, $uid ) = getpwent ) {
$uid{$uid}++;
}
File::Find::find( { wanted => \&wanted }, @path );
exit;
...
You can run passing zero or more path arguments. If no arguments are given then the current working directory is assumed.
# ./findnousers /home
Regards!
...JRF...
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP