07-20-2011
Default Path
Quote:
Originally Posted by
manutd
I need to check for the existence of a file *.log in a specific directory using a perl script.
Presently am not in that particular directory.
So i am using chdir ("/path/to/my/file)
And then i am using the -e in an if statement to check if it exists.
if (-e $File) {......}
$File contains the filename and maybe the path again.
My questions are what should be stored in this $ File exactly and how exactly should the chdir command be written.
Present Dir : /home/asdf/
DIr in which the file is present: /home/ghjk/
Hi,
if you check file existence, By Default is searches in current dir[default path].
chdir is used to change the default path.
if you check file existence after chdir, it will search the files in default location that is New default path.
Cheers,
Ranga.
This User Gave Thanks to rangarasan For This Post:
10 More Discussions You Might Find Interesting
1. Solaris
Hi,
I have a script which will check the fiel existence, the lines are as below
if !(test -d ./data) then
mkdir data
fi
In the first line error occurs as below
generatelicense.sh: syntax error at line 2: `!' unexpected
Where as this script works fine in linux OS.
How to solve... (2 Replies)
Discussion started by: krevathi1912
2 Replies
2. Shell Programming and Scripting
Hi,
I would like to check the existence of files (doesn;t matter the number of files) in a directory.
My file is named in the following manner (always ending with " myfile "). Can anybody give me some guidance?
EG:
abc1_myfile
sdfr_myfile
sffgd_myfile
and so on ......
My... (9 Replies)
Discussion started by: Raynon
9 Replies
3. AIX
i can able to transfer a file from build server(AIX)to webserver using ksh through ftp.my query is to check the existence of file while transfering from one server to other .i.e i need some command or script that checks the existence of file with same name in both server,within ftp syntax.
... (1 Reply)
Discussion started by: karthikprasathk
1 Replies
4. AIX
we have tranferred an ear from local server to remote server using ftp.consider, we have an ear file named a.ear in remote server,again if we transfer the same file named a.ear from local server to remote server.we need the kshell to check the existence of the ear file in remote server,and if the... (3 Replies)
Discussion started by: karthikprasathk
3 Replies
5. AIX
Hello
I am having a requirement like if there is no file in the directory then i need a message to pop on after the execution of the script.
My script basically does for File in `ls -t $DIRECTORY | tail -1`;
if there is no file the DIRECTORY then the script is simply exiting with out... (2 Replies)
Discussion started by: dsdev_123
2 Replies
6. AIX
I have requirement where i need to search for files which start with SALESORDER and PURCHASEORDER. i need to process the files with SALESORDER first and then PURCHASEORDER. If SALESORDER files are not there i dont want to process PURCHASEORDER and i want to come out of script. I have written a code... (4 Replies)
Discussion started by: dsdev_123
4 Replies
7. Shell Programming and Scripting
i want to check if the file is in the directory or not, and also it should be handle error conditions, like missing files and report the error and exit.
i did something like this:
file ="hello"
if !test -e "${file}"
then echo "No such files exist!"
exit 1
else
do something.......
fi
... (1 Reply)
Discussion started by: mingming88
1 Replies
8. Shell Programming and Scripting
I am using the following command to check for files on a Unix (Solaris 9) and on Linux:
if (-r *.) then
echo " las file found"
else
echo " no las file found"
endif
If no las file is present, the "no las file found" message is displayed. If a las file is present, however, I get... (9 Replies)
Discussion started by: phudgens
9 Replies
9. Shell Programming and Scripting
Hi All.
Pls help me with the command to check existence of files (I'll mention name of the file as regex) and proceed with my further processing if atleast one of them exists
in detail,
I've a dir /tmp/TURP, which may or may not have files named with "exter*.txt"
I need to check and... (2 Replies)
Discussion started by: skpvalvekar
2 Replies
10. Shell Programming and Scripting
hi
i wanted to check if the file exist or not(multiple files)
DIRE=/home/V478
if ;
then
echo "file present"
else
echo "file not present"
fi
But i am getting the error as
: [: unexpected operator/operand (3 Replies)
Discussion started by: ATWC
3 Replies
LEARN ABOUT DEBIAN
rfio_access
RFIO_ACCESS(3) Rfio Library Functions RFIO_ACCESS(3)
NAME
rfio_access - check existence/accessibility of a file/directory
SYNOPSIS
Under Unix:
#include <sys/types.h>
#include <unistd.h>
#include "rfio_api.h"
Under Windows/NT:
#include <sys/types.h>
#define R_OK 4
#define W_OK 2
#define X_OK 1
#define F_OK 0
#include "rfio_api.h"
int rfio_access (const char *path, int amode);
DESCRIPTION
rfio_access checks the existence or the accessibility of the file/directory path according to the bit pattern in amode using the real user
ID.
path specifies the logical pathname relative to the current directory or the full pathname.
amode the bit pattern is built by an OR of the constants defined in <unistd.h> under Unix or to be explicitly defined under Windows/NT:
R_OK test for read permission
W_OK test for write permission
X_OK test for search/execute permission
F_OK test for existence of the directory/file.
RETURN VALUE
This routine returns 0 if the operation was successful or -1 if the operation failed. In the latter case, serrno is set appropriately.
ERRORS
ENOENT The named file/directory does not exist.
EACCES Search permission is denied on a component of the path prefix or specified access to the file itself is denied.
EFAULT path is a NULL pointer.
ENOTDIR A component of path prefix is not a directory.
EINVAL amode is invalid.
ENAMETOOLONG The length of path exceeds CA_MAXPATHLEN or the length of a path component exceeds CA_MAXNAMELEN.
SENOSHOST Host unknown.
SENOSSERV Service unknown.
SECOMERR Communication error.
SEE ALSO
Castor_limits(4), rfio_chmod(3), rfio_stat(3)
AUTHOR
LCG Grid Deployment Team
LCG
$Date: 2010-04-05 09:51:26 +0200 (Mon, 05 Apr 2010) $ RFIO_ACCESS(3)