File exist checking error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting File exist checking error
# 1  
Old 07-16-2009
File exist checking error

Hi all,

I have following code:
Code:
export USERID=user
export BATCHHOSTIP=190.113.3.324

remotePath=/home/user
fileName=redbook.txt

EXIST=`ssh $USERID@$BATCHHOSTIP 'if [ -f $remotePath/$fileName ] ; then echo 0; else echo 1 ; fi'`
echo $EXIST

II run the code from other server. The redbook.txt file is exist in /home/user/ in server 190.113.3.324.

I dont know why it print out "1". The program ignore that the file is exist.

Then, I changed my code to:
Code:
export USERID=user
export BATCHHOSTIP=190.113.3.324

remotePath=/home/user
fileName=redbook.txt

EXIST=`ssh $USERID@$BATCHHOSTIP 'if [ -e $remotePath/$fileName ] ; then echo 0; else echo 1 ; fi'`
echo $EXIST

It print out "0". But, when I remove the redbook.txt from the location, the program still print out "0". Now, the code ignore the file is not exist.

Anybody have idea what's going on ?

thanks.. Smilie
# 2  
Old 07-17-2009
try putting double " inplace of single quote '
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Checking of file exist in different folder

Hi All, Seeking for your assistance to compare if the file in working directory is found on the DIR2 directory and if not found move the file in DIR2. ex. WORKING_DIR=/home/dir1/ file1.txt DIR2=/home/admin/users file1.txt what i did was found_nonempty='' for file in... (4 Replies)
Discussion started by: znesotomayor
4 Replies

2. HP-UX

Hpvmmodify: ERROR (host): The vswitch 'vmsw4' does not exist.

Hello Experts, I want to modify the CPU of my VM but when i am going to modify it , it showing the below error : hpvmmodify: ERROR (host): The vswitch 'vmsw4' does not exist. HPVM guest testhost configuration problems: Warning 1 on item vmsw4: Vswitch 'vmsw4' does not exist. These... (0 Replies)
Discussion started by: purushottamaher
0 Replies

3. Shell Programming and Scripting

Error while checking file existance

Kindly help on below script: << i='find ...' if then echo 'File Exists' else echo 'File Does Not Exist' >> If i has some file name then it runs properly but if i has nothing ( blank value) then it throws an error. I dont exactly remember right now but error seems like:... (2 Replies)
Discussion started by: ravigupta2u
2 Replies

4. Shell Programming and Scripting

Checking FTP server file exist or not

I am trying to delete old file in ftp server, after transferring new file successfully . but here i am checking both the file available or not using ls command. if both the file available means i need to get file_new and file_old file size as greater than zero. but i am getting only for... (3 Replies)
Discussion started by: elango963
3 Replies

5. UNIX for Dummies Questions & Answers

Checking if multiple directories exist

I need to create multiple directories if those directories do not exist already. How would you go by doing this. What I have so far. array=(one two three) for I in ${array} do if ] then mkdir ${I} fi doneI have a good feeling this is done incorrectly. The error I am... (2 Replies)
Discussion started by: jrymer
2 Replies

6. Red Hat

insmod Error inserting `/lib/raid456.ko` -1 File Exist

hi every one , Wondering if any of you experienced this During "Centos5.6" Boot .. ! 1)NOT USING MMCONFIG 2)insmod Error inserting `/lib/raid456.ko` -1 File Exist Dell PowerEdge T110 with 4sata Controllers with Centos2.6.18-238.9.1.el5xen installed . /boot on /dev/md0 / on ... (18 Replies)
Discussion started by: Saed
18 Replies

7. AIX

AIX cp error: "A file or directory in the path does not exist"

Hello fellow UNIX fans, I'm running AIX 4.3 and getting an error message “cp: /a/file2.db: A file or directory in the path does not exist” when I run the following command: cp /b/file.db /a/file2.db It stops every time about 95% of the way through the copy process at 1,073,741,312 bits. ... (3 Replies)
Discussion started by: Jackson123
3 Replies

8. Shell Programming and Scripting

Does not exist or unreadable error in windows ftp script

I have a file like this 07200900.SUP,in a windows directory I need to FTP this file to UNIX , the directory in unix is N:\orgs\Financial Aid\MIIS\0910\FTP I am getting this error miis_ftp.ELM_SUP.shl: =cd orgs/"Financial Aid"/"MIIS"/"0910"/"FTP" : not found IN THE LOG FILE Activities for Mon... (3 Replies)
Discussion started by: rechever
3 Replies

9. Shell Programming and Scripting

Error checking a file from previous file size

Hi, I'm currently trying to write a script that checks a log file for certain errors. Once checked it then records the filesize in another file. All this is fine, my problem is that the next time I do my error check I only want to check from previously recorded filesize to the end of file. I'm... (2 Replies)
Discussion started by: stuck1
2 Replies

10. HP-UX

Error: file </tmp/srw25108193> does not exist

Hi Everybody I need help from you guys. I'm getting this message on PC where i'm running Unix User using Reflection in order to get graphically format for Oracle Report Server. What is causing this msg and how to solve it? Regards and thanks in advance. Gege *Error: file... (0 Replies)
Discussion started by: cgege
0 Replies
Login or Register to Ask a Question