08-21-2007
I'm doing it in perl
Sorry if I wasn't clear.
I need to create a folder and if there is any errors like permission errors I want to let the user know about it. However I don't wish to overwrite the folder if it already exists. Also I need to do it inside a Perl script.
This is the workaround I came up with:
`ls log 2> /dev/null`; #check if the folder exists
if($?) { #if it doesn't create it
`mkdir log`;
$dirFlag = 1; #flag to know that dir was created
}
The bad thing about this is that it wont let the user know if there were any permission errors. In other words, if the folder wasn't created for some reason the program will crash later when I try to write to that folder.
So what I want to do is to somehow check, in my Perl code, the error code that UNIX spits out. The problem is that I'm getting the same error code number for both "File Permission" and "File exists" errors.
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am trying to set up a variable based on the name of the file.
function script_name {
if
then
job_name='MONITOR'
return job_name;
elsif
then
job_name='VERSION'
return job_name
fi
}
for i in `ls *log`
do
script_name $i
done. (4 Replies)
Discussion started by: oracle8
4 Replies
2. Shell Programming and Scripting
I am creating a script that will automatically use sftp to connect to a site and download a file, extract the tar and then delete the tar file once completed.
What I am stuck on is the error checking for this process.
Here is the code so far:
Now this works for me as is, but i need... (0 Replies)
Discussion started by: xianoth
0 Replies
3. Shell Programming and Scripting
hi
i have a file, i am reading line by line and checking a line contains a string ,
`grep "Change state" $LINE`
if
then
echo "The line contains---"
else
echo "The line does not contains---"
i need to check the return code , but i am getting an error
... (4 Replies)
Discussion started by: Satyak
4 Replies
4. Shell Programming and Scripting
I am currently wrapping up a assignment for one of my classes. I need help writing some error checking logic. The problems I am having are:
keeping track of the records I have deleted and reported it back using echo.
I have no idea how to do this.
ensuring that line numbers fall... (1 Reply)
Discussion started by: Boltftw
1 Replies
5. Programming
hi friends ,
i need c code for my app,
in my app the user can create the new user for the system,
while creating the new user ,i try to include the condition
the user name is not present in password.
my exe requrment is : the user name char is not present in password,if the password... (6 Replies)
Discussion started by: vasu28
6 Replies
6. Shell Programming and Scripting
i was just wondering how would you check , beside the lock method, if an instance of another code is already running and if it is then output a message to the user saying the program is already running and exit!! the code is in BOURNE SHELLL!!!
thanks in advance!! (3 Replies)
Discussion started by: bshell_1214
3 Replies
7. Shell Programming and Scripting
I have a short line of code that checks very rudimentary for duplicate code:
sort myfile.cpp | uniq -c | grep -v "^.*1 " | grep -v "}"
It sorts the file, counts occurrences of each line, removes single occurrences and removes the ubiquitous closing brace. The language is C++, but is easily... (3 Replies)
Discussion started by: figaro
3 Replies
8. Shell Programming and Scripting
#!/bin/ksh
#This script will check status of load balancer in AIX servers from hopbox
#Steps to do as folows :
#Login to server
#netstat -ani | grep <IP>
#check if the output contains either lo0 OR en0
#if the above condition matches, validation looks good
#else, send an email with impacted... (7 Replies)
Discussion started by: vinil
7 Replies
9. UNIX for Beginners Questions & Answers
Hi,
I am writing the shell script in ksh to check certain no of files exists,In my case there are 7 files exist like below
Sales1_timstamp.csv
Sales2_timstamp.csv
Sales3_timstamp.csv
Sales4_timstamp.csv
Sales5_timstamp.csv
Sales7_timstamp.csv
Sales7_timstamp.csv
Once all the files... (4 Replies)
Discussion started by: SRPR
4 Replies
LEARN ABOUT DEBIAN
mail::box::locker::multi
Mail::Box::Locker::Multi(3pm) User Contributed Perl Documentation Mail::Box::Locker::Multi(3pm)
NAME
Mail::Box::Locker::Multi - lock a folder in all ways which work
INHERITANCE
Mail::Box::Locker::Multi
is a Mail::Box::Locker
is a Mail::Reporter
SYNOPSIS
See Mail::Box::Locker
DESCRIPTION
The "::Multi" locker locks a folder in each way it can. This way, the chance is highest that any other program will leave the folder alone
during our access to it.
NFS-lock and Flock are tried. More may be added when the ways to lock are extended. DotLock overlaps with NFS-lock, but NFS-lock is
safer, so that version is preferred.
METHODS
Constructors
Mail::Box::Locker::Multi->new(OPTIONS)
You may also pass all OPTIONS understood by the initiated lockers used by the multi locker.
-Option --Defined in --Default
expires Mail::Box::Locker 1 hour
file Mail::Box::Locker undef
folder Mail::Box::Locker <undef>
log Mail::Reporter 'WARNINGS'
method Mail::Box::Locker 'MULTI'
timeout Mail::Box::Locker 10 seconds
trace Mail::Reporter 'WARNINGS'
use <all possible>
expires => SECONDS
file => FILENAME
folder => FOLDER
log => LEVEL
method => STRING|CLASS|ARRAY
timeout => SECONDS|'NOTIMEOUT'
trace => LEVEL
use => ARRAY-of-(NAMES|LOCKER)
Array of locker type NAMES or LOCKER objects to be used to lock one folder. The type NAMES are converted into objects. When you
create your own LOCKER objects, be sure to set the timeout very short (preferrably to 1).
Some locking types are not available on some platforms, so they will not be excluded from the default list (NFS POSIX Flock).
example: using a subset of multi-lockers
my $locker = Mail::Box::Locker::Multi->new(use => ['DOTLOCK','FLOCK']);
The Locker
$obj->filename([FILENAME])
See "The Locker" in Mail::Box::Locker
$obj->folder([FOLDER])
See "The Locker" in Mail::Box::Locker
$obj->lockers()
Returns a list with all locker objects used by this object.
$obj->name()
See "The Locker" in Mail::Box::Locker
Locking
$obj->hasLock()
See "Locking" in Mail::Box::Locker
$obj->isLocked()
See "Locking" in Mail::Box::Locker
$obj->lock(FOLDER)
See "Locking" in Mail::Box::Locker
$obj->unlock()
See "Locking" in Mail::Box::Locker
Error handling
$obj->AUTOLOAD()
See "Error handling" in Mail::Reporter
$obj->addReport(OBJECT)
See "Error handling" in Mail::Reporter
$obj->defaultTrace([LEVEL]|[LOGLEVEL, TRACELEVEL]|[LEVEL, CALLBACK])
Mail::Box::Locker::Multi->defaultTrace([LEVEL]|[LOGLEVEL, TRACELEVEL]|[LEVEL, CALLBACK])
See "Error handling" in Mail::Reporter
$obj->errors()
See "Error handling" in Mail::Reporter
$obj->log([LEVEL [,STRINGS]])
Mail::Box::Locker::Multi->log([LEVEL [,STRINGS]])
See "Error handling" in Mail::Reporter
$obj->logPriority(LEVEL)
Mail::Box::Locker::Multi->logPriority(LEVEL)
See "Error handling" in Mail::Reporter
$obj->logSettings()
See "Error handling" in Mail::Reporter
$obj->notImplemented()
See "Error handling" in Mail::Reporter
$obj->report([LEVEL])
See "Error handling" in Mail::Reporter
$obj->reportAll([LEVEL])
See "Error handling" in Mail::Reporter
$obj->trace([LEVEL])
See "Error handling" in Mail::Reporter
$obj->warnings()
See "Error handling" in Mail::Reporter
Cleanup
$obj->DESTROY()
See "Cleanup" in Mail::Box::Locker
$obj->inGlobalDestruction()
See "Cleanup" in Mail::Reporter
DIAGNOSTICS
Error: Package $package does not implement $method.
Fatal error: the specific package (or one of its superclasses) does not implement this method where it should. This message means that
some other related classes do implement this method however the class at hand does not. Probably you should investigate this and
probably inform the author of the package.
SEE ALSO
This module is part of Mail-Box distribution version 2.105, built on May 07, 2012. Website: http://perl.overmeer.net/mailbox/
LICENSE
Copyrights 2001-2012 by [Mark Overmeer]. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See
http://www.perl.com/perl/misc/Artistic.html
perl v5.14.2 2012-05-07 Mail::Box::Locker::Multi(3pm)