I keep getting an error at line 21, it doesn't like my if statement. Previously I have tried using (( )), but still get errors. The current error is that server_busy is not found. This is the script: added code tags --oombera
I need an IF statement that will compare the contents of the variable CX with the actual string "CP". ie. If the contents of $CX are NOT equal to the actual string "CP" then blah blah blah.
I have tried a number of things including the following.......
if ]; then
if ]; then
if ];... (2 Replies)
hi all. i just have a very small problem. i have a menu of 7 choices. i want an if statement so that if the user chooses anything except inside the 1 to 7 range, i can handle the error for it.
i tried this:
if ]
then
.......
fi
(but it dont work)
...any suggestions?
... (4 Replies)
The problem I am having here is that only the 1st option is executed, no matter if I pick yes or no. What am I doing wrong? How can I get this working right without resorting to a case statement?
echo "This is the max size your lvol can be:"
echo $MAXSIZE
echo
echo Do you want to max out... (2 Replies)
Hi I have a bash script like this
if
then
echo "A"
else
echo "B"
fi
$1 is something like 02350 (there is always a trailing '0')
and I would like to have an if based on the value of the digits after the 0.
Can anybody help?
Thanks,
Sarah (3 Replies)
Could someone help me out with this if statement? It's supposed to get a person's website, but it isn't working when I run it.
website=""
echo "Would you like to enter a website? Enter Yes/No"
read choice
if
then
while
do
echo "Please enter a website:";
read... (4 Replies)
Writing my script and I'm banging my head on the desk right now ...
My biggest problem is the 3rd IF statement where I check if the username exists. Doing the grep command on it's own in the shell gives me a 1 or 0 value. Running the script, it always returns a false value (runs the ELSE... (4 Replies)
Hi,
Here is a big head scratcher for me....
I'm creating a loop with while reading lines from a file called example.txt:
#!/bin/sh
while read line
do
some command > another file ----- output to another file
done < example.txt
I would like that another file to be unique for every... (5 Replies)
echo "Enter the variable: " "
read var1
echo " "
for i in ib eb atm
do
if ; then
mv properties environment.properties
break
else
echo "No changes to $var1 "
fi
done
When i run and enter the eb it's not working.Any suggestions please.. (7 Replies)
Hi All,
I am writing an if statement to check multiple conditions, but when I try to execute the script it is breaking at the point of if statement by showing the issue below.
Code I am using is given below.
if -a ]
then
....
else
...
fi
I am not understanding... (3 Replies)
Discussion started by: ginrkf
3 Replies
LEARN ABOUT OPENSOLARIS
echo
echo(1) User Commands echo(1)NAME
echo - echo arguments
SYNOPSIS
/usr/bin/echo [string]...
DESCRIPTION
The echo utility writes its arguments, separated by BLANKs and terminated by a NEWLINE, to the standard output. If there are no arguments,
only the NEWLINE character is written.
echo is useful for producing diagnostics in command files, for sending known data into a pipe, and for displaying the contents of environ-
ment variables.
The C shell, the Korn shell, and the Bourne shell all have echo built-in commands, which, by default, is invoked if the user calls echo
without a full pathname. See shell_builtins(1). sh's echo, ksh's echo, ksh93's echo, and /usr/bin/echo understand the back-slashed escape
characters, except that sh's echo does not understand a as the alert character. In addition, ksh's and ksh93's echo does not have an -n
option. sh's echo and /usr/bin/echo have an -n option if the SYSV3 environment variable is set (see ENVIRONMENT VARIABLES below). csh's
echo and /usr/ucb/echo, on the other hand, have an -n option, but do not understand the back-slashed escape characters. sh and ksh deter-
mine whether /usr/ucb/echo is found first in the PATH and, if so, they adapt the behavior of the echo builtin to match /usr/ucb/echo.
OPERANDS
The following operand is supported:
string A string to be written to standard output. If any operand is "-n", it is treated as a string, not an option. The following char-
acter sequences is recognized within any of the arguments:
a Alert character.
Backspace.
c Print line without new-line. All characters following the c in the argument are ignored.
f Form-feed.
New-line.
Carriage return.
Tab.
v Vertical tab.
\ Backslash.
n Where n is the 8-bit character whose ASCII code is the 1-, 2- or 3-digit octal number representing that character.
USAGE
Portable applications should not use -n (as the first argument) or escape sequences.
The printf(1) utility can be used portably to emulate any of the traditional behaviors of the echo utility as follows:
o The Solaris 2.6 operating environment or compatible version's /usr/bin/echo is equivalent to:
printf "%b
" "$*"
o The /usr/ucb/echo is equivalent to:
if [ "X$1" = "X-n" ]
then
shift
printf "%s" "$*"
else
printf "%s
" "$*"
fi
New applications are encouraged to use printf instead of echo.
EXAMPLES
Example 1 Finding how far below root your current directory is located
You can use echo to determine how many subdirectories below the root directory (/) is your current directory, as follows:
o Echo your current-working-directory's full pathname.
o Pipe the output through tr to translate the path's embedded slash-characters into space-characters.
o Pipe that output through wc -w for a count of the names in your path.
example% /usr/bin/echo $PWD | tr '/' ' ' | wc -w
See tr(1) and wc(1) for their functionality.
Below are the different flavors for echoing a string without a NEWLINE:
Example 2 /usr/bin/echo
example% /usr/bin/echo "$USER's current directory is $PWDc"
Example 3 sh/ksh shells
example$ echo "$USER's current directory is $PWDc"
Example 4 csh shell
example% echo -n "$USER's current directory is $PWD"
Example 5 /usr/ucb/echo
example% /usr/ucb/echo -n "$USER's current directory is $PWD"
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of echo: LANG, LC_ALL, LC_CTYPE, LC_MES-
SAGES, and NLSPATH.
SYSV3 This environment variable is used to provide compatibility with INTERACTIVE UNIX System and SCO UNIX installation scripts. It is
intended for compatibility only and should not be used in new scripts. This variable is applicable only for Solaris x86 platforms,
not Solaris SPARC systems.
EXIT STATUS
The following error values are returned:
0 Successful completion.
>0 An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
|CSI |Enabled |
+-----------------------------+-----------------------------+
|Interface Stability |Committed |
+-----------------------------+-----------------------------+
|Standard |See standards(5). |
+-----------------------------+-----------------------------+
SEE ALSO ksh93(1), printf(1), shell_builtins(1), tr(1), wc(1), echo(1B), ascii(5), attributes(5), environ(5), standards(5)NOTES
When representing an 8-bit character by using the escape convention n, the n must always be preceded by the digit zero(0).
For example, typing: echo 'WARNING: 7' prints the phrase WARNING: and sounds the "bell" on your terminal. The use of single (or double)
quotes (or two backslashes) is required to protect the "" that precedes the "07".
Following the , up to three digits are used in constructing the octal output character. If, following the n, you want to echo addi-
tional digits that are not part of the octal representation, you must use the full 3-digit n. For example, if you want to echo "ESC 7" you
must use the three digits "033" rather than just the two digits "33" after the .
2 digits Incorrect: echo "