09-11-2013
It is almost always illogical to continue after not finding a data file. What are you planning to do? Make up defaults - like setting defaults in the absence of data.
A lot of applications will ignore the absence of/or an empty config file, but the application has reasonable defaults defined. This kind of thing- checking defaults - is done when the program starts.
If you are having issues with a long-running program aborting on file not found, consider using a system call like access() to enumerate all required file resources when the program starts. Instead of running for 5 minutes, then aborting.
You do not have to open a file to see if you can read or write to it.
You simply cannot process application data from a file if it is not there. Or permissions are wrong. Or because you don't want a 3:00am telephone call. The program has to abort. Period.
Other kinds of resources may go offline - like a tape drive - then be brought back online or mounted with the correct tape. You can, again, at the get-go enumerate resources, then tell the person running the report to mount the right tape.
For report programs, a huge percent of the lines of code often deal with checking parameters and resources, getting usernames and passwords, etc. The other 10% or so actually processes data. You have to do a ton of upfront work before trying to run the actual report code. This is true for lots of different kinds of apps.
The way your question is stated it is not clear.
Last edited by jim mcnamara; 09-11-2013 at 06:58 AM..
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
$ errpt | more
IDENTIFIER TIMESTAMP T C RESOURCE_NAME DESCRIPTION
3074FEB7 0802050205 T H fscsi1 ADAPTER ERROR
B8113DD1 0802050205 T H fcs1 LINK ERROR
B8113DD1 0802050205 T H fcs1 LINK ERROR
3074FEB7 0802050205 T H fscsi0 ADAPTER ERROR
B8113DD1 ... (0 Replies)
Discussion started by: mcastill66
0 Replies
2. AIX
$ errpt | more
IDENTIFIER TIMESTAMP T C RESOURCE_NAME DESCRIPTION
3074FEB7 0802050205 T H fscsi1 ADAPTER ERROR
B8113DD1 0802050205 T H fcs1 LINK ERROR
B8113DD1 0802050205 T H fcs1 LINK ERROR
3074FEB7 0802050205 T H fscsi0 ADAPTER ERROR
B8113DD1 ... (2 Replies)
Discussion started by: mcastill66
2 Replies
3. UNIX for Dummies Questions & Answers
Hi all, dummy here.... I have major errors on entering the shell. On login I get:
-bash: dircolors: command not found
-bash: tr: command not found
-bash: fgrep: command not found
-bash: grep: command not found
-bash: grep: command not found
-bash: id: command not found
-bash: [: =: unary... (12 Replies)
Discussion started by: wcmmlynn
12 Replies
4. UNIX for Dummies Questions & Answers
while entering into vim insert mode some garbage is getting printed in to the file
could some one help to avoid this . (1 Reply)
Discussion started by: Gopi Krishna P
1 Replies
5. Shell Programming and Scripting
Is there a way to do this?
while getopts "n:g:m:i:p:d:a:" OPTION
do
case $OPTION in
...
if i do a ./script.sh -n john -u user -p password, it will output:
name= john
./script.sh: illegal option -- u
Is there a way to skip over errors so that -p will get processed as well?
By... (7 Replies)
Discussion started by: etranman1
7 Replies
6. Shell Programming and Scripting
Mysql log has something like below:
I need a bash shell script that will do the following:
1) The script will scan the mysql.log file constantly in real time (something like tail -F mysql.log)
2) If it encounters 5 consecutive identical lines then it would invoke some commands (say... (4 Replies)
Discussion started by: proactiveaditya
4 Replies
7. Ubuntu
Hi folks,
Ubuntu 9.04
I have an old box not running for years. I just dig it out from the store room. On running;
$ sudo aptitude update
......
......
Err http://hk.archive.ubuntu.com jaunty/main Packages
404 Not Found
Err http://hk.archive.ubuntu.com jaunty/restricted Packages
... (1 Reply)
Discussion started by: satimis
1 Replies
8. Homework & Coursework Questions
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
I am trying to convert a C language program over to Sparc Assembley and I am getting Undefined first referenced... (4 Replies)
Discussion started by: kenjiro310
4 Replies
9. Programming
co
#! /usr/bin/perl
use strict;
use warnings;
use diagnostics;
my $amount=""; my $bain; ; my $code="";
my $date;my $day;my $line; my $mo; my $LNUM = 0;
my $xyz=""; my $yr;
$yr = 2015;
my $F; my @F;
while (<>) {
chop;
++$LNUM;
@F = split(';');
if ( $F eq "Date" )... (1 Reply)
Discussion started by: hpk
1 Replies
10. Shell Programming and Scripting
I need to split a file based on headers found
Input file
file1 content:
ADD
john
mickey
DROP
matt
sam
output of file F1
john
mickey
output of file F2
matt
sam (5 Replies)
Discussion started by: Diddy
5 Replies
LEARN ABOUT CENTOS
tapeinfo
TAPEINFO(1) General Commands Manual TAPEINFO(1)
NAME
tapeinfo - report SCSI tape device info
SYNOPSIS
tapeinfo -f <scsi-generic-device>
DESCRIPTION
The tapeinfo command reads various information from SCSI tape drives that is not generally available via most vendors' tape drivers. It
issues raw commands directly to the tape drive, using either the operating system's SCSI generic device ( e.g. /dev/sg0 on Linux,
/dev/pass0 on FreeBSD) or the raw SCSI I/O ioctl on a tape device on some operating systems.
One good time to use 'tapeinfo' is immediately after a tape i/o operation has failed. On tape drives that support HP's 'tapealert' API,
'tapeinfo' will report a more exact description of what went wrong.
Do be aware that 'tapeinfo' is not a substitute for your operating system's own 'mt' or similar tape driver control program. It is intended
to supplement, not replace, programs like 'mt' that access your operating system's tape driver in order to report or set information.
OPTIONS
The first argument, given following -f , is the SCSI generic device corresponding to your tape drive. Consult your operating system's doc-
umentation for more information (for example, under Linux these are generally start at /dev/sg0 under FreeBSD these start at /dev/pass0).
Under FreeBSD, 'camcontrol devlist' will tell you what SCSI devices you have, along with which 'pass' device controls them. Under Linux,
"cat /proc/scsi/scsi" will tell you what SCSI devices you have.
BUGS AND LIMITATIONS
This program has only been tested on Linux with a limited number of tape drives (HP DDS4, Seagate AIT).
AVAILABILITY
tapeinfo is currently being maintained by Robert Nelson <robertnelson@users.sourceforge.net> as part of the 'mtx' suite of programs. The
'mtx' home page is http://mtx.sourceforge.net and the actual code is currently available there and via SVN from http://source-
forge.net/projects/mtx.
SEE ALSO
mt(1),mtx(1),scsitape(1),scsieject(1),loaderinfo(1)
TAPEINFO1.0 TAPEINFO(1)