Sponsored Content
Top Forums Shell Programming and Scripting File exists, but cannot be opened.How to check- whether it could be opened to read when it exists Post 302638657 by rxg on Thursday 10th of May 2012 01:57:24 PM
Old 05-10-2012
File exists, but cannot be opened.How to check- whether it could be opened to read when it exists

Hi

Code:
#Testing for  file existence 
if [ -f $DIR/SCHOOL_FAC.txt ]; then   
  echo 'SCHOOL data is available for processing'   
else   
  echo 'SCHOOL DATA IS NOT AVAILABLE FOR PROCESSING'  
  :

i wrote a script, where it begins by checking if file exists or not.
If it exists, it truncates the database table and bcp's new data from file into the table.

Now, I had a situtation, where the file exists, but couldnot open,
and since my above statements checks for file existence, the database table is truncated and the table became empty.
When tried to bcp the file...the file couldnot be opened and it failed.

Now the database table lost its old data and since file couldnot be opened, the bcp couldnot load data into the table.

How can i check whether file is readable,so that i can take of truncating the table only when the file is readable and can be opened.

Any answer is appreciated, with respect to my above problem.

Thank You.Smilie
 

10 More Discussions You Might Find Interesting

1. Programming

Check if file exists + ulp :S

Hi all! I know that this may not be the best forum to ask ulp and eagle related question. But the guys from eagle didn't know the answer and this is the BEST programming forum I know :D How can I check if a file exists while programming eagle's ulp's? There is not much information on-line.... (2 Replies)
Discussion started by: ruben.rodrigues
2 Replies

2. Shell Programming and Scripting

Check to see if a file exists?

Hi. I'd like to have an IF-Then-Else statement where I can check to see if a file exists? We have the Bourne Shell by default. I'm looking for the syntax to do something like this: if myfile.txt exists then ...my code else ...my code end if Any help would be greatly... (5 Replies)
Discussion started by: buechler66
5 Replies

3. Shell Programming and Scripting

Script to check file exists

Hi, I am trying to write a script which checks if any file exists with "*.log" or "*.out" in Directory below is the code #------------------ path=/abd/xyz/ if ; then echo "Good" else echo "Failure" fi #-------------------------- its always going to else part and printing... (8 Replies)
Discussion started by: ch33ry
8 Replies

4. Shell Programming and Scripting

how to check to see if a file exists?

I want to write a script to see if various files exist. What I want to do is have the script search in various directories if a file exist, and if not, then output something like "/path/file does not exist". I don't actually know of how to check and see if a file exists or not. What I have in mind... (2 Replies)
Discussion started by: astropi
2 Replies

5. Shell Programming and Scripting

How to check if a file exists in a directory?

I want to perform SQL *Loader operation only if a file named "load.txt" exists in a directory "/home/loc/etc". Please help how to check this with a if condition. (8 Replies)
Discussion started by: vel4ever
8 Replies

6. Shell Programming and Scripting

Check whether file exists in directory

Hi guys, I am beginner trying to learn unix. So any help is welcomed. My requirement is to check whether is a file exists in a particular directory or not. The directory path and filename are taken dynamically with user interaction. So the program should continue only if the $filename... (1 Reply)
Discussion started by: maris_markur
1 Replies

7. Shell Programming and Scripting

Check if file exists or not

Hi, I want to check if the file exists or not in the directory. i am trying below code but not working. File="/home/va59657/Account_20090213*.dat" echo "$File" if ]; then echo "file found" else echo "file not found" fi However i am getting file not found even if file exits as... (5 Replies)
Discussion started by: Vivekit82
5 Replies

8. Shell Programming and Scripting

How to check more than 1 file specified files exists?

Hi all, One of my script crated created 2 files in a dirs Output.log and Output.tmp. Now in another script i need to check if both of the above mentioned files are present in a directory or not. I know to check one file but need to check both the files. Anyone could please tell me how... (3 Replies)
Discussion started by: girijajoshi
3 Replies

9. Shell Programming and Scripting

To check if file exists

Hi, I have the below code written. However I am not getting the desired output I am checking if the particular path has file in it. #!/bin/bash ls -l /IRS2/IRS2_ODI/INFILE/*LS* 1>/dev/null 2>/dev/null if then echo $? echo "File Exists" fi ... (3 Replies)
Discussion started by: Shanmugapriya D
3 Replies

10. UNIX for Beginners Questions & Answers

Check if file exists

I need to check whether a file exists and has been changed. The file should contain a specific string. The file should also have been changed within the last ten seconds. How do I do that? (3 Replies)
Discussion started by: locoroco
3 Replies
IBUS-TABLE-CREATEDB(1)													    IBUS-TABLE-CREATEDB(1)

NAME
ibus-table-createdb - create ibus-table database from table source SYNOPSIS
ibus-table-createdb [ [ -n name ] [ --name name ] ] [ [ -s source ] [ --source source ] ] [ [ -e extra ] [ --extra extra ] ] [ [ -p pinyin ] [ --pinyin pinyin ] ] [ -o ] [ --no-create-index ] [ -i ] [ --create-index-only ] [ -d ] [ --debug ] DESCRIPTION
ibus-table-createdb creates a database for ibus-table from a source table. OPTIONS
This program follows the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below. -n database-file specifies the file name for the binary database for the IME. The default is ''. If the file name of the database is not specified, the file name of the source file before the first '.' will be appended with '.db' and that will be used as the file name of the database. -s source-file specifies the file which contains the source of the IME. The default is ''. -e extra-words-file specifies the file name for the extra words for the IME. The default is ''. -p pinyin-file specifies the source file for the pinyin. The default is '/usr/share/ibus-table/data/pinyin_table.txt.bz2'. -o Do not create an index for a database (Only for distribution purposes, a normal user should not use this flag!) -i Only create an index for an existing database. Specifying the file name of the binary database with the -n or --name option is required when this option is used. -d Print extra debug messages. EXAMPLES
ibus-table-createdb -n ipa-x-sampa.db -s ipa-x-sampa.txt Create the binary database ``ipa-x-sampa.db'' from the source file ``ipa-x-sampa.txt''. ibus-table-createdb -i -n ipa-x-sampa.db Create an index for the database ``ipa-x-sampa.db''. AUTHOR
This manual page was written by Mike FABIAN <mfabian@redhat.com>. Apr 18, 2013 IBUS-TABLE-CREATEDB(1)
All times are GMT -4. The time now is 08:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy