- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Perl "system" command
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
Forums
Discussions
Discussions
Discussions
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
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
10-18-2004 04:51 AM
10-18-2004 04:51 AM
I am trying to run the following in a Perl program,
system("find /tmp -name $file_name -exec chown maestro:unison {} \;");
I get the following error message:
/tmp/security.log
sh[2]: -exec: not found.
How can I fix this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2004 05:14 AM
10-18-2004 05:14 AM
Re: Perl "system" command
Try-
system("find /tmp -name '$file_name' ... unison {} \\;");
I assume $file_name is a perl variable and has valid entries. The single quotes around it will be sure any funny named files don't confuse the shell.
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2004 05:37 AM
10-18-2004 05:37 AM
Solution1. $file_name has some space or other non-allowed character and should be quoted
2. You should not use system ()
--8<---
use File::Find;
my $uid = (getpwnam "maestro")[2];
my $gid = (getgrnam "unison")[2];
find (sub {
$_ eq $file_name or return;
chown $uid, $gid, $_;
}, "/tmp");
-->8---
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2004 08:07 AM
10-18-2004 08:07 AM
Re: Perl "system" command
I used the following
use File::Find;
sub changed {
if ( $_ eq $file_name ) {
chown (104, 102, $_);
chmod 0777, $File::Find::name;
}; }
find(\&changed, '/tmp/logs');
which does not work. However, if I changed the line
if ( $_ eq $file_name ) {
to
if ( $_ eq "security.log" ) {
the actual file name, it works.
Enclosing $file_name in quotes,either double or single, do not work either. I am using Perl 5.8.4
Any suggestions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2004 08:18 AM
10-18-2004 08:18 AM
Re: Perl "system" command
If you read it from a file, remember to do a chomp on it to remove the trailing \n.
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2004 08:30 AM
10-18-2004 08:30 AM