Hi,
I have sequencer where i have to check for file existence then proceed further.I have used execute command activity and used test -e in command and passed parameter #filename#.But the job is showing a warning message and job is not detecting the file.
I have used return value =0 for file existence and 1 for file does not exist.
The warning is
Parameter 4 (' and return value is 1') does not start with a keyword
The log messsage :
seqtest..JobControl (@Execute_Command_440): Executed: test -e /test/stg/file.txt
Reply=1
Output from command ====>
SH: test: argument expected
The file is present on unix.
Thanks!
check for file existence
Moderators: chulett, rschirm, roy
check for file existence
sravanthi
Have you checked your syntax? According to wikipedia: http://en.wikipedia.org/wiki/Test_(Unix)
1. To test whether a file is nonexistent or empty, type:
if test ! -s "$1"
then
echo $1 does not exist or is empty.
fi
If the file specified by the first positional parameter to the shell procedure, $1, does not exist, the test command displays an error message. If $1 exists and has a size greater than 0, the test command displays nothing.
Note: There must be a space between the -s function and the file name.
The quotation marks around $1 ensure that the test works properly even if the value of $1 is a null string. If the quotation marks are omitted and $1 is the empty string, the test command displays the error message
1. To test whether a file is nonexistent or empty, type:
if test ! -s "$1"
then
echo $1 does not exist or is empty.
fi
If the file specified by the first positional parameter to the shell procedure, $1, does not exist, the test command displays an error message. If $1 exists and has a size greater than 0, the test command displays nothing.
Note: There must be a space between the -s function and the file name.
The quotation marks around $1 ensure that the test works properly even if the value of $1 is a null string. If the quotation marks are omitted and $1 is the empty string, the test command displays the error message
-
- Participant
- Posts: 467
- Joined: Tue Mar 20, 2007 6:36 am
- Location: Chennai
- Contact:
When you say you are returning "1" do you mean you have an "exit 1" in your script? If so, this behavior is expected. You see, if the script exits with a status other than 0 (0 for success) it signifies an error. That's the reason your sequence is throwing up a warning. Try changing your script to print something and then parse it in the sequence to find if the file existed.
Minhajuddin
<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
-
- Charter Member
- Posts: 193
- Joined: Tue Sep 05, 2006 8:01 pm
- Location: Australia
Re: check for file existence
From your error message that "test" command did not run.It was expecting an argument. Try quoting the arguments.sravanthi wrote:Hi,
I have sequencer where i have to check for file existence then proceed further.I have used execute command activity and used test -e in command and passed parameter #filename#.But the job is showing a warning message and job is not detecting the file.
I have used return value =0 for file existence and 1 for file does not exist.
The warning is
Parameter 4 (' and return value is 1') does not start with a keyword
The log messsage :
seqtest..JobControl (@Execute_Command_440): Executed: test -e /test/stg/file.txt
Reply=1
Output from command ====>
SH: test: argument expected
The file is present on unix.
Thanks!
Might want to put that test command in a script and put in error handling in the script and ensure you return a error code back to the calling program.
In my job I have the same file checking condition.So I have called a UNIX script from execute command stage with filename as parameter.
From script you need to return value.The script will look like below one
in_dir=$1
in_file=$2
if [ -s "$in_dir/$2" ]
then
exit 0
else
exit 1
fi
Now in trigger condition do the checking with this return value 0/1.
Thanks
Shaonli
From script you need to return value.The script will look like below one
in_dir=$1
in_file=$2
if [ -s "$in_dir/$2" ]
then
exit 0
else
exit 1
fi
Now in trigger condition do the checking with this return value 0/1.
Thanks
Shaonli
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: