Sponsored Content
Full Discussion: shell problem
Top Forums UNIX for Dummies Questions & Answers shell problem Post 6690 by Perderabo on Monday 10th of September 2001 10:18:16 AM
Old 09-10-2001
Well when two commands are linked together by && the second one is executed only if the first succeeds. So something like:

[ $DEBUG = y ] && echo DEBUG is set >&2

will echo "DEBUG is set" if and only if $DEBUG is equal to y. It's a one line "if" statement. The >&2 sends the output of the echo to stderr rather than stdout.

"set -x" will always succeed. So the second && is a way to do two statements based on the results of the first test. I think it's poor syntax and I would use:

[ "$DEBUG" = Y ] && { set -x ; echo "enter tablespace_end_backup" >&2 ; }

Of course, you can strongly argue for a full "if" statement in this case, but many programmers (including me) try to keep debug statements to one like so they can easily be commented out to improve performance.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Shell Problem.

Hello and Good day to all. Im having a problem here and would like to know if there is any solution that could overcome my problem. I have changed from bash to csh (c-shell) yesterday on my Linux 7.2. When i do $echo $SHELL i can see the output /bin/csh which means ihave succesfully landed on... (4 Replies)
Discussion started by: ###1tomato
4 Replies

2. UNIX for Advanced & Expert Users

Shell Problem

Dear Members; I changed ,by mistake ,the root shell in /etc/passwd and logged out. Thereafter, I can no more have a prompt when trynig to log in as root. How to solve this pb ? Regards :confused: (8 Replies)
Discussion started by: oss
8 Replies

3. UNIX for Dummies Questions & Answers

shell problem

What are the different type of shell available in UNIX and how to change the shell? just this 2 question pls help mi (4 Replies)
Discussion started by: yeah016
4 Replies

4. Shell Programming and Scripting

Problem in shell

hi, can any one tell a solution for the following : I want to append 10 spaces and a string say "ok" to 12 digit number which is stored in a varialbe & display using shell script. (1 Reply)
Discussion started by: Sandeep Kale
1 Replies

5. Shell Programming and Scripting

Shell Problem

Hi all, until yesturday grep command was running in KSH .... I was executing this command ls -l | grep *.sh But today its not working at all ... Should I check any of the setting ... I am not getting whats the problem ... I have relogged to unix box but it didn't... (14 Replies)
Discussion started by: dhananjayk
14 Replies

6. Shell Programming and Scripting

problem with if in shell

Hi, My sheel script has below statement: if; then When I run iam getting the below error: -bash: syntax error near unexpected token `then' What is wrong with that statement: Plz help me. (2 Replies)
Discussion started by: pradeep_script
2 Replies

7. Shell Programming and Scripting

shell problem

Hello! Can you please help me on a lab at school: I have to to write a shell program which reads all .C files from the current directory and prints for each file how many '#define' directives it has and for each macro defined how many times is it used in that file. Can you suggest how can i... (1 Reply)
Discussion started by: dark_knight
1 Replies

8. Shell Programming and Scripting

Problem in shell script

hi...i create a script which reads data from file and compare that the data which is entered by me through keyboard...i can easily read first two contents of file..i am facing the problem to read other contents.. structure of my file is username:password:username1:password1.......and so on ... (1 Reply)
Discussion started by: shubhig15
1 Replies

9. Shell Programming and Scripting

shell problem

problem: I give the source of a c program.. is required to indicate how many times is called each function defined in the program and line number there is a call. let's say i have lab2.c: float dist(int *a,int *b,int n){ int i=0; double d=0; for (i=1;i<=n;i++){ d+=pow((a-b),2); }... (4 Replies)
Discussion started by: sherpeledenis
4 Replies

10. UNIX for Dummies Questions & Answers

shell problem

this picture for print You didn't do the question. Go back. if $1 = 0 but until now it give me this message what i should be do ? http://img717.imageshack.us/img717/6137/eeevb.jpg (2 Replies)
Discussion started by: NeeZaaR
2 Replies
ATF-CHECK(1)						    BSD General Commands Manual 					      ATF-CHECK(1)

NAME
atf-check -- executes a command and analyzes its results SYNOPSIS
atf-check [-s qual:value] [-o action:arg ...] [-e action:arg ...] [-x] command DESCRIPTION
atf-check executes a given command and analyzes its results, including exit code, stdout and stderr. Test cases must use atf-sh(3)'s atf_check builtin function instead of calling this utility directly. In the first synopsis form, atf-check will execute the provided command and apply checks specified by arguments. By default it will act as if it was run with -s exit:0 -o empty -e empty. Multiple checks for the same output channel are allowed and, if specified, their results will be combined as a logical and (meaning that the output must match all the provided checks). In the second synopsis form, atf-check will print information about all supported options and their purpose. The following options are available: -s qual:value Analyzes termination status. Must be one of: exit:<value> checks that the program exited cleanly and that its exit status is equal to value. The exit code can be omit- ted altogether, in which case any clean exit is accepted. ignore ignores the exit check. signal:<value> checks that the program exited due to a signal and that the signal that terminated it is value. The signal can be specified both as a number or as a name, or it can also be omitted altogether, in which case any signal is accepted. Most of these checkers can be prefixed by the 'not-' string, which effectively reverses the check. -o action:arg Analyzes standard output. Must be one of: empty checks that stdout is empty ignore ignores stdout file:<path> compares stdout with given file inline:<value> compares stdout with inline value match:<regexp> looks for a regular expression in stdout save:<path> saves stdout to given file Most of these checkers can be prefixed by the 'not-' string, which effectively reverses the check. -e action:arg Analyzes standard error (syntax identical to above) -x Executes command as a shell command line, executing it with the system shell defined by ATF_SHELL. You should avoid using this flag if at all possible to prevent shell quoting issues. EXIT STATUS
atf-check exits 0 on success, and other (unspecified) value on failure. ENVIRONMENT
ATF_SHELL Path to the system shell to be used when the -x is given to run commands. EXAMPLES
The following are sample invocations from within a test case. Note that we use the atf_check function provided by atf-sh(3) instead of exe- cuting atf-check directly: # Exit code 0, nothing on stdout/stderr atf_check 'true' # Typical usage if failure is expected atf_check -s not-exit:0 'false' # Checking stdout/stderr echo foobar >expout atf_check -o file:expout -e inline:"xx yy " 'echo foobar ; printf "xx yy " >&2' # Checking for a crash atf_check -s signal:sigsegv my_program # Combined checks atf_check -o match:foo -o not-match:bar echo foo baz SEE ALSO
atf-sh(1) BSD
October 5, 2014 BSD
All times are GMT -4. The time now is 10:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy