Sponsored Content
Top Forums Shell Programming and Scripting if statement with two conditions -e, && Post 74925 by vgersh99 on Tuesday 14th of June 2005 11:50:44 AM
Old 06-14-2005
Quote:
Originally Posted by yongho
Question: I just started learning shell scripting a few days ago and I was under the assumption that you didn't need to typeset anything.
you don't.
if you don't,

count=$((count + 1))
becomes
count=$(($count + 1))

Quote:
Originally Posted by yongho
One of my previous counters looked like this (in a while statement, not an if statement:
var1=`expr $var1 + $var2`
..and it worked.
this NOT using ksh/bash builtin capabilities for doing simple integer math.
Quote:
Originally Posted by yongho
But when I tried the expr command in the if statement, it didn't increment at all. Would you know why this is? Could it be because once you enter an if statement, you must use different rules?
nope, that's not it.
are you saying that the 'expr ' increment did not work, but the 'count=$((count+1))' did?
there must be something else different in your 'while' loop.
is your 'while' loopbeing piped with data?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

using && in if statement ..

Hi All, Can some one tell me how to get run the following: data1="hello" data2="world" if then { echo "good afternnon" } else { echo " good morning" } fi The above code gives me an error ad below : ./if.h: line 3: ' (7 Replies)
Discussion started by: jisha
7 Replies

2. Shell Programming and Scripting

multiple conditions in if using && operator

VARIABLE="project" if && ] then echo "VARIABLE is not empty" fi this is not working what is wrong in the syntax?? (2 Replies)
Discussion started by: codeman007
2 Replies

3. Shell Programming and Scripting

PHP read large string & split in multidimensional arrays & assign fieldnames & write into MYSQL

Hi, I hope the title does not scare people to look into this thread but it describes roughly what I'm trying to do. I need a solution in PHP. I'm a programming beginner, so it might be that the approach to solve this, might be easier to solve with an other approach of someone else, so if you... (0 Replies)
Discussion started by: lowmaster
0 Replies

4. Programming

IF && statement problem

Hello there, My first time on the forums, glad to be here :) I'm completely new to programming in PHP and I have a question which I hope someone could help me with. I am currently using this statement: if(($session == 2) && ($item == Dagger) && ($item2 == Dagger)){ ... (5 Replies)
Discussion started by: Hero
5 Replies

5. Shell Programming and Scripting

How to write If statement using && and operator in Unix

Hi What is the syntax for if statement using && and || operator? if && ] || here its giving me an error to this if statement any suggestion?? (2 Replies)
Discussion started by: Avi
2 Replies

6. Shell Programming and Scripting

if statement with '&&' gives error

Hi, I'm using the && operator in if statement: if ; then exp $UID/$PWD@$ORACLE_SID FILE=./DUMP/$TODAY$CONCAT_STR$USERNAME.dmp STATISTICS=NONE LOG=./LOG/$TODAY$CONCAT_STR$USERNAME.log elif ; then expdp $UID/$PWD@$ORACLE_SID DIRECTORY=./DUMP/ DUMPFILE=$TODAY$CONCAT_STR$USERNAME.dmp... (8 Replies)
Discussion started by: priya001
8 Replies

7. Shell Programming and Scripting

Using && in if statement with 3 expressions

how do you write an if statement for something like if ((expr 1 >= expr 2 && expr 3 >= expr 4) && expr 5 <= expr 6) if ((TRUE && TRUE) && TRUE) then condition... i've done it this way but it doesn't seem to work. if (] && "$ex_day" -le "$curr_day" ); then condition... (3 Replies)
Discussion started by: angilulu
3 Replies

8. Shell Programming and Scripting

GNU & BSD Makefile Directives & Conditions Compatibility

Firstly, I would like to apologize if this is not the appropriate sub-forum to post about GNU/BSD makefile scripting. Though my code is in C++, because I am focusing on the makefile I thought it would go better in shell scripting. Please correct me if I am wrong. Secondly, I am not interested in... (0 Replies)
Discussion started by: AntumDeluge
0 Replies

9. Shell Programming and Scripting

SFTP Shell Script Get & Delete && Upload & Delete

Hi All, Do you have any sample script, - auto get file from SFTP remote server and delete file in remove server after downloaded. - only download specify filename - auto upload file from local to SFTP remote server and delete local folder file after uploaded - only upload specify filename ... (3 Replies)
Discussion started by: weesiong
3 Replies

10. Shell Programming and Scripting

Bash: How to use read with conditions & loops

Hello, Below I try to control that the input is good an IP : #!/bin/bash cp /home/scripts/choice_interfaces.txt /home/scripts/interfaces.txt chmod 644 /home/scripts/interfaces.txt echo -e "Please enter the network informations into the /etc/network/interfaces file, complete them below... (9 Replies)
Discussion started by: Arnaudh78
9 Replies
OSASCRIPT(1)						    BSD General Commands Manual 					      OSASCRIPT(1)

NAME
osascript -- execute AppleScripts and other OSA language scripts SYNOPSIS
osascript [-l language] [-s flags] [-e statement | programfile] [argument ...] DESCRIPTION
osascript executes the given script. It was designed for use with AppleScript, but will work with any Open Scripting Architecture (OSA) lan- guage. To get a list of the OSA languages installed on your system, use osalang(1). For documentation on AppleScript itself, see <http://www.apple.com/applescript>. osascript will look for the script in one of the following three places: 1. Specified line by line using -e switches on the command line. 2. Contained in the file specified by the first filename on the command line. This file may be plain text or a compiled script. 3. Passed in using standard input. This works only if there are no filename arguments; to pass arguments to a STDIN-read script, you must explicitly specify ``-'' for the script name. Any arguments following the script will be passed as a list of strings to the direct parameter of the ``run'' handler. For example: a.scpt: on run argv return "hello, " & item 1 of argv & "." end run % osascript a.scpt world hello, world. The options are as follows: -e statement Enter one line of a script. If -e is given, osascript will not look for a filename in the argument list. Multiple -e options may be given to build up a multi-line script. Because most scripts use characters that are special to many shell programs (e.g., AppleScript uses single and double quote marks, ``('', ``)'', and ``*''), the statement will have to be correctly quoted and escaped to get it past the shell intact. -l language Override the language for any plain text files. Normally, plain text files are compiled as AppleScript. -s flags Modify the output style. The flags argument is a string consisting of any of the modifier characters e, h, o, and s. Multiple modi- fiers can be concatenated in the same string, and multiple -s options can be specified. The modifiers come in exclusive pairs; if con- flicting modifiers are specified, the last one takes precedence. The meanings of the modifier characters are as follows: h Print values in human-readable form (default). s Print values in recompilable source form. osascript normally prints its results in human-readable form: strings do not have quotes around them, characters are not escaped, braces for lists and records are omitted, etc. This is generally more useful, but can introduce ambiguities. For example, the lists '{"foo", "bar"}' and '{{"foo", {"bar"}}}' would both be displayed as 'foo, bar'. To see the results in an unambiguous form that could be recompiled into the same value, use the s modifier. e Print script errors to stderr (default). o Print script errors to stdout. osascript normally prints script errors to stderr, so downstream clients only see valid results. When running automated tests, how- ever, using the o modifier lets you distinguish script errors, which you care about matching, from other diagnostic output, which you don't. SEE ALSO
osacompile(1), osalang(1) HISTORY
osascript in Mac OS X 10.0 would translate ' ' characters in the output to ' ' and provided c and r modifiers for the -s option to change this. osascript now always leaves the output alone; pipe through tr(1) if necessary. Prior to Mac OS X 10.4, osascript did not allow passing arguments to the script. Mac OS X June 10, 2003 Mac OS X
All times are GMT -4. The time now is 05:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy