I need some help on a perl script. The script is to open a dir and print out the date of last modification on all files. I'm been trying this code but it doesn't work.
keep getting "Can't stat"!!! What did I do wrong? Appreciate any help...
Last edited by Scott; 11-08-2010 at 07:54 PM..
Reason: Please use code tags
I'm having a problem verifying a directory's permissions using the stat() command. I want to flag an error condition if the directory is WRITABLE by either group or other. This is the code I'm using:
if (stat(dirname,&statbuf) == -1) {
fprintf(stderr,"Unable to run stat() command\n");
... (3 Replies)
Hi there, I need some help with cp files from one directory into several others. The code is as follows:
SUB=`ls src_directory | wc -l`
OUT_LOOP=$(($SUB / $MK_NUMS))
IN_LOOP=$(($SUB % $MK_NUMS))
COUNT=$MK_NUMS
while ]
do
mkdir dst_directory$COUNT
ls -1 src_directory |... (4 Replies)
#!/bin/ksh
cp /etc/apache2/vhosts.d/orginal/test-yast2_vhost.conf-bk /etc/apache2/vhosts.d/test-yast2_vhost.conf
/usr/sbin/rcapache2 graceful
when i ran this script I'm getting following error.
cp: cannot stat /etc/apache2/vhosts.d/orginal/test-yast2_vhost.conf-bk no such file or directory... (1 Reply)
Hi all,
I want to check whether a file is not updated in last 15 minutes, for this i need to get timestamp of file, (yyyy:mm:dd:hh:mi:ss). I dont have access to STAT command :(.
Please suggest a program or command to do this .
Thanks,
Saravana (1 Reply)
this is my script
x=1
o=0
while
do
fi ];then (this check is a certain extension with a number exist)
let x++
else
mv /var/log/mrnet.log.1.gz /var/log/mrnet.log.$x.gz
o=1
fi
done
mrnet.log.1.gz exist already... (1 Reply)
Please review the issue below and tell me what I need to do. I cannot copy the zip file.
$ ls -l
total 10
drwxrwx--- 1 root vboxsf 0 Feb 1 16:10 sf_Temp
drwxrwx--- 2 root vboxsf 4096 Jan 31 17:59 sf_VBoxShared
dr-xr-xr-x 6 oracle root 2048 Dec 19 09:20 VBOXADDITIONS_4.2.6_82870
$ cp -r... (2 Replies)
Hi
Please review this script and let me know what i need to do.
This is my script
#!/bin/bash
#SCRIPT: forms.sh
#PURPOSE: Process a file line by line with redirected while-read loop.
#PURPOSE: and copy the forms to the follder
foldername=sample_dir
mkdir -p $foldername
while read... (5 Replies)
Hi,
I am getting below error in Solaris 10 SPARC when trying to issue a search on /var/tmp partition
Below is the query
/bin/find /var/tmp/ -type f -atime +1
Below is the result
/bin/find: stat() error <File> : No such file or directory (28 Replies)
So on my external hard drive, I am trying to copy one folder into another folder
sudo cp /albiero /home
and get the error message
cannot stat ‘/albiero': No such file or directory
Though both folders exist
drwxr-xr-x 44 root root 4096 Oct 31 15:15 albiero
drwxr-xr-x 2 root ... (2 Replies)
Good day.
I am trying to install the latest version of LAST program (last.cbrc.jp) on my Windows64bit using Cygwin64. I successfully downloaded it and followed the instructions on how to install it. However, when I tried to run the command "make install prefix=~", I got this error, as shown... (0 Replies)
Discussion started by: nicole_john_
0 Replies
LEARN ABOUT SUSE
io::dir
IO::Dir(3pm) Perl Programmers Reference Guide IO::Dir(3pm)NAME
IO::Dir - supply object methods for directory handles
SYNOPSIS
use IO::Dir;
$d = IO::Dir->new(".");
if (defined $d) {
while (defined($_ = $d->read)) { something($_); }
$d->rewind;
while (defined($_ = $d->read)) { something_else($_); }
undef $d;
}
tie %dir, 'IO::Dir', ".";
foreach (keys %dir) {
print $_, " " , $dir{$_}->size,"
";
}
DESCRIPTION
The "IO::Dir" package provides two interfaces to perl's directory reading routines.
The first interface is an object approach. "IO::Dir" provides an object constructor and methods, which are just wrappers around perl's
built in directory reading routines.
new ( [ DIRNAME ] )
"new" is the constructor for "IO::Dir" objects. It accepts one optional argument which, if given, "new" will pass to "open"
The following methods are wrappers for the directory related functions built into perl (the trailing `dir' has been removed from the
names). See perlfunc for details of these functions.
open ( DIRNAME )
read ()
seek ( POS )
tell ()
rewind ()
close ()
"IO::Dir" also provides an interface to reading directories via a tied hash. The tied hash extends the interface beyond just the directory
reading routines by the use of "lstat", from the "File::stat" package, "unlink", "rmdir" and "utime".
tie %hash, 'IO::Dir', DIRNAME [, OPTIONS ]
The keys of the hash will be the names of the entries in the directory. Reading a value from the hash will be the result of calling
"File::stat::lstat". Deleting an element from the hash will delete the corresponding file or subdirectory, provided that "DIR_UNLINK" is
included in the "OPTIONS".
Assigning to an entry in the hash will cause the time stamps of the file to be modified. If the file does not exist then it will be
created. Assigning a single integer to a hash element will cause both the access and modification times to be changed to that value.
Alternatively a reference to an array of two values can be passed. The first array element will be used to set the access time and the
second element will be used to set the modification time.
SEE ALSO
File::stat
AUTHOR
Graham Barr. Currently maintained by the Perl Porters. Please report all bugs to <perl5-porters@perl.org>.
COPYRIGHT
Copyright (c) 1997-2003 Graham Barr <gbarr@pobox.com>. All rights reserved. This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
perl v5.12.1 2010-04-26 IO::Dir(3pm)