10-01-2008
Quote:
Originally Posted by
Arunprasad
you are using err file (redirecting the error to stderr)wright?
lets take
ls data >err 2>&1 | tee -a somefile
if [ ! -s err ]
then
{do whatever you want}
fi
here as per the code the err file will load with some error message when failure occurs in ls.
is it feasible?
this is all done and dusted now but i'd just like to say to Arunprasad, you were correct, it's -s i need to use, because the file gets created regardless of any errors. the indication of failure is size of the file.
thank you.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am using the time command in a script however the output of the time command will display on my screen but not my output file. Any Ideas on how to fix this?
> cat test.sh
#############################
#!/usr/bin/sh
for COMMAND in pwd
do
time ${COMMAND}
done | sed "s/^/ ... (4 Replies)
Discussion started by: 2dumb
4 Replies
2. Shell Programming and Scripting
I am using ksh on an AIX box.
I would like to redirect the stdout and stderr to a file but also show them on the terminal. Is this possible? I have tried tee within my file without success.
This is the code I have so far
exec > imp.log 2>&1 | tee exec 1>&1
I am new to shell scripting, so... (3 Replies)
Discussion started by: podzach
3 Replies
3. Shell Programming and Scripting
exam is a ksh script. In command line I enter: exam 3 param_2 param_3 param_4.
In exam how can I get the value of the parameter which position is specified by the first argument.
Simply doing this DOES NOT work:
offset=$1
value=$$offset
can you figure out any possible way to interpret a... (5 Replies)
Discussion started by: i27oak
5 Replies
4. Solaris
Hello all,
I have a script that I am trying to execute and redirect the output to a file, but I have trouble in redirection. The cron job is running properly as I see it in the mail.
This is what I am doing
In crontab file,
0 4 * * * somescript.sh > /some_location/`date '+%m%d%y_%H%M'`.log... (9 Replies)
Discussion started by: grajp002
9 Replies
5. Shell Programming and Scripting
Hi,
I need to create one KSH which will send mail to set of recipients using "mailx" command like below.
mailx -s "Test mail" "test@yahoo.com, test@gmail.com" <$output.txt
The recipients are in different domains (like yahoo, gmail, etc.).
My requirement is, if any mail is undelivered,... (1 Reply)
Discussion started by: Matrix2682
1 Replies
6. Shell Programming and Scripting
Hi,
I have perl script which is calling an external command using "system()" with argument.
But i am not able to capture the output.Even tried with backtick also with no luck.
.
.
$number=<>;
system ("cmd $number >output.txt"); (2 Replies)
Discussion started by: rasingraj
2 Replies
7. Programming
Hello,
i'm trying to implement the times() function and i'm programming in C.
I'm using the "struct tms" structure which consists of the fields:
The tms_utime structure member is the CPU time charged for the execution of user instructions of the calling process.
The tms_stime structure... (1 Reply)
Discussion started by: g_p
1 Replies
8. Shell Programming and Scripting
I have a script to send an email like below. Problem is, the if ..fi block is not getting executed, and is coming as a part of the email body. Can anyone take a look at this? :confused:
Log file shows this:
SEND_MAIL.prog: line 64:
: command not found
echo "Input Parameters"
echo... (11 Replies)
Discussion started by: mansmaan
11 Replies
9. Shell Programming and Scripting
Hello all,
I would like to create a for loop or whatever is quick that will print the one’s place of a number for 1-N times
say for example a printed page formatting is 132 characters wide,
I would like a single line
123456789012345678901234567890... ...012
That is 132 characters long. I... (11 Replies)
Discussion started by: KmJohnson
11 Replies
10. UNIX for Dummies Questions & Answers
Hi
Please can you help how do I count the number of specific characters or words that appear in a file? (8 Replies)
Discussion started by: fretagi
8 Replies
LEARN ABOUT BSD
syserrlst
SYSERRLST(3) Library Functions Manual SYSERRLST(3)
NAME
syserrlst, __errlst - read system error messages from file
SYNOPSIS
char *
syserrlst(err)
int err;
char *
__errlst(err, path);
int err;
char *path;
DESCRIPTION
Syserrlst(3) reads the error message string corresponding to err from the file /etc/syserrlst.
__errlst(3) reads the error message string corresponding to err from the file path. The file path must be in the format described in
syserrlst(5).
NULL is returned if err is out of bounds (negative or greater than the highest message number in /etc/syserrlst or path) or if the error
message file can not be opened. It is the responsibility of the caller (strerror(3)) to check for and properly handle the NULL return.
RETURN VALUE
NULL if an error was encountered in opening the error message file, if the error was out of bounds, or if the file did not start with the
correct magic number. Otherwise a char * is returned pointing to a static buffer containing the text of the error message.
ERRORS
syserrlst(3) and __errlst(3) can return any of the errors for the open(2), lseek(2), or read(2) system calls.
SEE ALSO
perror(3), strerror(3), syserrlst(5)
HISTORY
syserrlst(3), and __errlst(3) were created for 2.11BSD with the aim of saving 2kb of Data space in programs which called perror(3), or str-
error(3).
BUGS
The information is stored in a static buffer.
3rd Berkeley Distribution March 26, 1996 SYSERRLST(3)