Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

define a custom error message

Posted on 2003-03-25
5
Medium Priority
?
320 Views
Last Modified: 2010-04-21
Hi All,

How to define a custom error message to stderr?

I don't want to use redirect standard output to a file!

Thanks a lot!

best regards,
dp
0
Comment
Question by:d_p2
  • 2
  • 2
5 Comments
 
LVL 1

Expert Comment

by:rob-g
ID: 8202136
To output on stderr redirect the command output to file descriptor 2, e.g.

echo "ERROR:..." >&2
0
 

Author Comment

by:d_p2
ID: 8202269
hi rob-g,

i wrote a shell script, test.sh:

/bin/bash
echo "error">&2
exit 0

when i test it in shell
#./test.sh 2>test.error

it simply hang in the console, how to solve it?

Thanks

regards,
dp
0
 
LVL 1

Accepted Solution

by:
rob-g earned 400 total points
ID: 8202323
The details that I gave do work in Korn shell, i.e the script would be

=====================
#!/bin/ksh
echo "ERROR" >&2
exit 0
=====================

Maybe you need to hash-bang (#!) your /bin/bash line.

Otherwise I can't help as I don't use bash and I don't know how if it handles file descriptors differently.
0
 
LVL 5

Expert Comment

by:ecw
ID: 8204044
Like rob-g says, you need the #! /bin/bash.  Otherwise the first thing the script will do is start another invocation of bash, which IIRC, displays prompt to stderr, which you've redirected and thus never see.
0
 

Author Comment

by:d_p2
ID: 8207416
Hi rob-g,

You are right, i forget to place #!  
Thanks a lot!

regards,
dp
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses
Course of the Month12 days, 6 hours left to enroll

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question