Self referencing script error message


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Self referencing script error message
# 8  
Old 01-31-2011
If you want the line number; the line in the script try:


Code:
ms:/u/purdym>cat /tmp/d
#!/usr/bin/ksh
echo "This error occured on line: $LINENO."

ms:/u/purdym>/tmp/d
This error occured on line: 2.
ms:/u/purdym>

# 9  
Old 01-31-2011
That'd work but the only problem is $LINENO returns the line number of itself. Not where the error was located. So I need something that will look in the script and return where the error itself is
# 10  
Old 01-31-2011
(Off topic. Avoid the variable name $LINENO - it is a largely undocumented reserved variable name and can change it's value).

Actually .... this may be "on-topic" if it is in the O/P's script.

Totally on-topic. It doesn't apply to all Shells but $LINENO is the current line in the Shell Script in many. I have seen other variants.
http://alasir.com/books/bsd/398-402.html

Advise change the name of your variable.

Last edited by methyl; 01-31-2011 at 07:34 PM.. Reason: Convincing myself that the $LINENO issue has happened again.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

UNIX script error message

I have this UNIX script code with a query to export sql table in Oracle and export to csv file. The code gets the data correctly. However, when I run the script second time, I got the error message "not spooling currently" and shows the older data in csv file. When I delete the csv file and run... (5 Replies)
Discussion started by: Hope
5 Replies

2. UNIX for Beginners Questions & Answers

UNIX script error message

Greeting!! I wrote the below script to e-mail me only file names in a specific directory when a file is delayed for some time in a that directory. I am getting unexpected eof error message. I don't want any email if the folder is blank.(if the condition is not met) I am not getting the email at... (4 Replies)
Discussion started by: Hope
4 Replies

3. Shell Programming and Scripting

How to deliver an error message from script?

Hi I have a script that pick up a file on another server, and place it on a solaris server, but I came across the following error: mget HLR01_21092014? 200 Port command successful 150 Opening data channel for file transfer. HLR01_21092014: No space left on device 426 Connection closed;... (18 Replies)
Discussion started by: fretagi
18 Replies

4. Shell Programming and Scripting

Passing error message back to script

I have one script that calls another script during execution. The other script does some processing, then either returns with exit 0 (if successful), or exits with error code numbers (if failed). However, in addition to the error code, I would like for that second script to be able to pass a... (4 Replies)
Discussion started by: AcerAspirant
4 Replies

5. Shell Programming and Scripting

Shell Script Referencing I/O

Is it possible to design a shell script to reference something that queries for input? (This is not to make a script to ssh) For instance if I have a command that when run, it does something like: %<Some command> User's password? Would it be possible to write a script to input something... (1 Reply)
Discussion started by: Prodiga1
1 Replies

6. Programming

Symbol referencing error

Hey everyone, I can't figure out this symbol referencing error after looking at it for the longest time, and I figured some fresh eyes might be able to point something out I am overlooking. Undefined first referenced symbol in... (1 Reply)
Discussion started by: fromatz
1 Replies

7. Shell Programming and Scripting

Suppress error message in shell script

Hi All this is a simple script #! /bin/bash FileCnt=`ls -lrt $DIR/* | wc -l` echo $FileCnt how could i escape the error msg if there are no files in $DIR ls: /home/sayantan/test/files/cnt/*: No such file or directory 0 Looking forward for a quick reply Regards, Newbie... (3 Replies)
Discussion started by: newbie07
3 Replies

8. Shell Programming and Scripting

Error message while executing the shell script

Hi All, When I am trying to execute the below shell script I got this error message. script ========== #!/bin/bash /usr/java/jdk1.5.0_10/bin/java - classpath /var/lib/asterisk/agi-bin/mysql-connector-java-3.0.15-ga-bin.jar/: /var/lib/asterisk/agi-bin/jarfiles:... (4 Replies)
Discussion started by: ajayyaduwanshi
4 Replies

9. Programming

symbol referencing error

Undefined first referenced symbol in file std::basic_ostream<char, std::char_traits<char> >::operator<<(int)/var/tmp//ccTR std::cerr /var/tmp//ccTRcjui.o std::cout /var/tmp//ccTRcjui.o... (1 Reply)
Discussion started by: suhasini
1 Replies

10. Shell Programming and Scripting

problem with script and syntax error message

Hi I have the following script and have problem debugging the problems. The function of this script is to make sure the entire file is being received (the filesize of a data is not changing after 20 seconds) and start moving the file to another directory. This script should be started every 30mins.... (5 Replies)
Discussion started by: ReV
5 Replies
Login or Register to Ask a Question