Sponsored Content
Top Forums Shell Programming and Scripting If statement with unmatched condition Post 302940291 by Don Cragun on Friday 3rd of April 2015 03:51:19 AM
Old 04-03-2015
Is this part of a homework assignment?

What utility are you using to process this statement?

What diagnostic is it printing when you try to compile or run this code?

How are the variables $InputLine and $fields[] defined?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

else unmatched

I'm getting an else unmatched error on the script below.. For info : SYDB is the database name entered as a param on the command line. #Check the DB name HBDB=`sql $SYDB <<_END_ | grep '^|' | grep -v dbase | sed 's/|//g' | sed 's/ //g' set autocommit on; \p\g set lockmode... (7 Replies)
Discussion started by: b.hamilton
7 Replies

2. UNIX for Dummies Questions & Answers

Multiple Condition If statement

Hi, I would like to create an IF statement where if a variable is equal to at least one of 2 (or more) values then the script proceeds. For example: TEST_VAR=2 if ; then echo success! else echo failure fi I understand that the above syntax is wrong but I feel it must be close. Any... (1 Reply)
Discussion started by: msb65
1 Replies

3. Shell Programming and Scripting

`for' unmatched

:b:Hi guys, I am getting this error in this piece of code, Any help will be appreciate rypidoc.shl: syntax error at line 79 : `for' unmatched ##Determine if there is a file to process ls 3526*.dat > /dev/null 2>&1 if then exit fi for i in 3526*.dat do # Capture just the file... (2 Replies)
Discussion started by: rechever
2 Replies

4. Shell Programming and Scripting

Condition statement in perl

#!/usr/bin/perl $output1 = "/home/log.txt" $output2 = "/home/grep.txt" #Statement1 creates an output file called log.txt. #Statement2 greps a line from log.txt and store the result in grep.txt I want to create a condition where if the file grep.txt is empty repeat process. Thanks. (1 Reply)
Discussion started by: sureshcisco
1 Replies

5. Shell Programming and Scripting

An issue with condition statement in shell script

Hello forum members. please go through the below mentioned issue and let me know the right solution. I have to write a script which runs another script .the executable script take input parmeters.so iam writing the the script below . Sample Code:Begins #! /bin/ksh echo " enter... (2 Replies)
Discussion started by: rajkumar_g
2 Replies

6. UNIX for Dummies Questions & Answers

LINUX Multiple condition in IF Statement - Pls help

Hi All, I am trying to put multiple conditions in an IF Statement (using $$). the Linux script somehow doesnt like it. The logic I am trying to implement is as follows, 1. I will first search for DateFile.txt 2. If it exists & there is a P_BUS_DATE value in it, then assign the date value... (5 Replies)
Discussion started by: dsfreddie
5 Replies

7. Shell Programming and Scripting

Unmatched <<

Hi, I am running sinple ksh script . From some reason it failed on the following error: ./ogg_status.sh: syntax error at line 16 : `<<' unmatched Please advise. #!/usr/bin/ksh export ORACLE_HOME=/software/oracle/DB10gR2 export LD_LIBRARY_PATH=/software/oracle/DB10gR2/lib:/usr/lib... (4 Replies)
Discussion started by: yoavbe
4 Replies

8. Shell Programming and Scripting

If condition and for loop within sed statement

Hi, I tried to go through a lot of online material but could not find concrete solution. My issues is like this : I've got a input file like this : <a> <startDate>19700101000000</startDate> <endDate>20300101000000</endDate> </a> ... (12 Replies)
Discussion started by: Shaishav Shah
12 Replies

9. Shell Programming and Scripting

Two condition in if statement

Hi, I need to put two condition in if statement, but it is not working. Please suggest. if ---------- Post updated at 07:05 AM ---------- Previous update was at 06:55 AM ---------- Also when i put below command in script it is not running, but manually it is running ... (4 Replies)
Discussion started by: learnbash
4 Replies

10. Shell Programming and Scripting

<< unmatched error

Hi all, I want to call a plsql package that does not return any value. I am using the following script to do so: sqlplus $UserNamePwd <<EOF set head off begin test_pkg.procedure('$DebugFlag'); end; exit EOF if then log_message "procedure failed." exit 1 fi exit $? I... (2 Replies)
Discussion started by: reshma15193
2 Replies
bc(1)							      General Commands Manual							     bc(1)

NAME
bc - Provides a processor for arbitrary-precision arithmetic language SYNOPSIS
bc [-cl] [file...] The bc command is an interactive program that provides unlimited precision arithmetic. It is a preprocessor for the dc command. STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: bc: XCU5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. OPTIONS
[Tru64 UNIX] Compiles file, but does not invoke dc. Includes a library of mathematical functions. Also sets the number of digits retained after the decimal point (the scale) to 20; by default the scale is 0. OPERANDS
Pathname of a text file containing program statements. After file has been exhausted, standard input is read. DESCRIPTION
[Tru64 UNIX] The bc command invokes dc automatically, unless the -c (compile only) option is specified. If the -c option is specified, the output from bc goes to the standard output. The bc command lets you specify an input and output base in decimal, octal, or hexadecimal (the default is decimal). The command also has a scaling provision for decimal point notation. The syntax for bc is similar to that of the C language. The bc command takes input first from the specified file. When bc reaches the end of the input file, it reads standard input. In the following description of syntax for bc, letter means one of the letters a-z. Comments Comments are enclosed in /* and */. Names Simple variables: letter Array elements: letter[expression] The words ibase, obase, and scale Other Operands Arbitrarily long numbers with optional sign and decimal point. Number of significant decimal digits Number of digits to right of decimal point Operators + - * / % ^ (% is remainder; ^ is power) ++ -- (prefix and suffix; apply to names) == <= >= != <> = =+ =- =* =/ =% ^= += -= *= /= %= Statements expression {statement;...;statement} if (expression) statement while (expression) statement for (expression;expression;expression) statement (null statement) break quit Function Definitions define letter ( letter,...,letter ) { auto letter,...,letter statement;...statement return ( expression ) } Functions in -l Math Library sine cosine exponential log arctangent Bessel function General Syntax All function parameters are passed by value. The value of a statement that is an expression is displayed, unless the main operator is an assignment. A semicolon or newline character separates statements. Assignments to scale control the number of decimal places printed on output and maintained during multiplication, division, and exponentiation. Assignments to ibase or obase set the input and output number radix, respectively. The same letter may refer to an array, a function, and a simple variable simultaneously. All variables are global to the program. Auto- matic variables are pushed down during function calls. When you use arrays as function parameters, or define them as automatic variables, empty brackets must follow the array name. All for statements must have all three expressions. The quit statement is interpreted when read, not when executed. EXIT STATUS
The following exit values are returned: Successful completion. An error occurred. EXAMPLES
When you enter bc expressions directly from the keyboard, press the End-of-File key sequence to end the bc session and return to the shell command line. To use bc as a calculator, proceed as follows: Enter: $ bc 1/4 The system responds as follows: 0 Enter: scale = 1 /* Keep 1 decimal place */ 1/4 The system responds as follows: 0.2 Enter: scale = 3 /* Keep 3 decimal places */ 1/4 The system responds as follows: 0.250 Enter: 16+63/5 The system responds as follows: 28.600 Enter: (16+63)/5 The system responds as follows: 15.800 Enter: 71/6 The system responds as follows: 11.833 Enter: 1/6 The system responds as follows: 0.166 You may type the comments (enclosed in /* */), but they are provided only for your information. The bc command displays the value of each expression when you press <Return>, except for assignments. To convert numbers from one base to another, proceed as follows: Enter: bc obase = 16 /* Display numbers in Hexadecimal */ ibase = 8 /* Input numbers in Octal */ 12 The system responds as follows: A Enter: 123 The system responds as follows: 53 Enter: 123456 The system responds as follows: A72E To write and run C-like programs, proceed as follows: Create the following file prog.bc: /* compute the factorial of n */ define f(n) { auto i, r; r = 1; for (i=2; i<=n; i++) r =* i; return (r); } Enter: bc -l prog.bc This interprets the bc program saved in prog.bc, then reads more bc command statements from standard input (the keyboard). Starting the bc command with the -l option makes the math library available. This example uses the e (exponential) function from the math library, and f is defined in the program prog.bc. Enter: e(2) /* e squared */ The system responds as follows: 7.38905609893065022723 Enter: f(5) /* 5 factorial */ The system responds as follows: 120 Enter: f(10) /* 10 factorial */ The system responds as follows: 3628800 The statement following a for or while statement must begin on the same line. To convert an infix expression to Reverse Polish Notation (RPN), enter: Enter: bc -c (a * b) % (3 + 4 * c) The system responds as follows: lalb* 3 4lc*+%ps. This compiles the bc infix-notation expression into one that the dc command can interpret. The dc command evaluates extended RPN expressions. In the compiled output, the lowercase l before each variable name is the dc subcommand to load the value of the vari- able onto the stack. The p displays the value on top of the stack, and the s. discards the top value by storing it in register . (dot). You can save the RPN expression in a file for dc to evaluate later by redirecting the standard output of this command. ENVIRONMENT VARIABLES
The following environment variables affect the execution of bc: Provides a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization vari- ables contain an invalid setting, the utility behaves as if none of the variables had been defined. If set to a non-empty string value, overrides the values of all the other internationalization variables. Determines the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multibyte characters in arguments). Determines the locale for the for- mat and contents of diagnostic messages written to standard error. Determines the location of message catalogues for the processing of LC_MESSAGES. FILES
Mathematical library. Desk calculator proper; uses bc as preprocessor. SEE ALSO
Commands: awk(1), dc(1) Standards: standards(5) bc(1)
All times are GMT -4. The time now is 02:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy