It's UWAweek 48

help2003/help4407

This forum is provided to promote discussion amongst students enrolled in Open Source Tools and Scripting.

Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.

How do I ask a good question?
Displaying the 6 articles in this topic
Showing 6 of 564 articles.
Currently 4 other people reading this forum.


 UWA week 12 (1st semester, week 4) ↓
SVG not supported

Login to reply

👍?
helpful
2:58pm Wed 23rd Mar, ANONYMOUS

Hi, here some quick questions in today demo, we get debugging code like if [[ conditions ]] then echo "xxxx" > /dev/stderr exit 0 fi question is: for echo "xxxx" > /dev/stderr , why we need write it into /dev/stderr, what is /dev/stderr for. and for "exit 0", is it only for telling people that your program running successfully? best regards


SVG not supported

Login to reply

👍?
helpful
12:11pm Thu 24th Mar, ANONYMOUS

If I understand the lecture correctly, I believe that > /dev/stderr means that any output of error messages will be kept in stderr (Standard Error Output), which is separated from the messages you see on screen. In short, you put error messages away. For 'exit 0', it simply indicates that the commands were successfully executed. Hopefully this helps :)


SVG not supported

Login to reply

👍?
helpful
12:32pm Thu 24th Mar, Michael W.

ANONYMOUS wrote:
> Hi, here some quick questions > in today demo, we get debugging code like > if [[ conditions ]] > then echo "xxxx" > /dev/stderr > exit 0 > fi > > question is: > for echo "xxxx" > /dev/stderr , why we need write it into /dev/stderr, what is /dev/stderr for. > > and for "exit 0", is it only for telling people that your program running successfully? > > best regards
Hi, As someone else has pointed out more recently, we use stderr in order to keep error messages, status updates, etc (i.e. not directly relevant to the purpose of the program) away from the program outputs that you, presumably, are interested in. I used exit 0 in the case of the usage message, because it's common Unix practice to type a command name without arguments (or sometimes with -h flag) if you just want to know the calling arguments. On that basis, you are getting back what you expect , so exit 0 (ie success) is reasonable. For genuine errors, exit 1 (or some other positive integer) is entirely appropriate. Makes sense? Cheers MichaelW


 UWA week 14 (1st semester, week 6) ↓
SVG not supported

Login to reply

👍?
helpful
10:13am Tue 5th Apr, ANONYMOUS

> > Hi, here some quick questions > > in today demo, we get debugging code like > > if [[ conditions ]] > > then echo "xxxx" > /dev/stderr > > exit 0 > > fi
I was looking at this demo again and I noticed that this conditional exits the script before actually executing anything, is this anti-bugging just used to test and then removed to actually run the script, or does it need to be modified to allow the script to run (instead of exiting with success and not actually doing anything) Thank you


SVG not supported

Login to reply

👍?
helpful
10:58am Tue 5th Apr, ANONYMOUS

Sorry I forgot we added the head functionality so it does work fine, I'm confused as to why we are exiting with 0 and not 1 when the incorrect number of arguments are used though


SVG not supported

Login to reply

👍?
helpful
8:04pm Tue 5th Apr, Michael W.

The exit status is precisely that; did the program successfully complete (i.e. get to the end without having some function fail). In a sense, that is not the same as complete successfully (ie do something sensible). By antibugging you are, in effect, forcing a doomed program to fall over early and with a diagnostic message indicating probable cause, rather the wasting resources or producing junk results. Makes sense? Cheers MichaelW

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  1:17AM Sep 14 2022
Privacy policy