Sponsored Content
Top Forums Shell Programming and Scripting Question on using "[[ ]]" in lieu of IF Construct Post 302284615 by sunpraveen on Friday 6th of February 2009 12:50:12 AM
Old 02-06-2009
Question on using "[[ ]]" in lieu of IF Construct

Unix gurus,

I have a piece of code as below.

Code:
[[ -n ${ORACLE_SID} ]] && INST="${ORACLE_SID}" || INST="${TWO_TASK}"

I know that the above code can be used in lieu of an IF construct. I also know that the above code can be extended for the "true" condition to include more than one command (as below):

Code:
[[ -n ${ORACLE_SID} ]] && INST="${ORACLE_SID}" && echo "INST=${INST}" || INST="${TWO_TASK}"

But I am unable to extend the "false" condition to include more than one command.

Desired Output using "[[ ]]" instead of IF construct:

Code:
if the variable ORACLE_SID is set, then
command 1;
command 2;
else
command 1;
command 2;

How can I achieve it? Any tips or suggestions?


TIA,

Regards,

Praveen
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

2. UNIX and Linux Applications

A question/problem about oracle "tns listener" and "enterprise manager"

hi, I have * an IBM P550 machine, * an AIX 5.3 running on it and * an oracle database, already installed on it. The problem (or question of my own) is: Oracle tns listener, "CT_LISTENER", and the enterprise manager (EM) of the instance, which is uniq instance and called... (0 Replies)
Discussion started by: talipk
0 Replies

3. UNIX for Advanced & Expert Users

A question/problem about oracle "tns listener" and "enterprise manager"

hi, I have a problem about the Oracle related components. I'm not able to find any answer yet, and waiting for your responses... Here is the configuration of my system: * an IBM P550 machine, * an AIX 5.3 running on it and * an oracle database, already installed on it. The problem (or... (1 Reply)
Discussion started by: talipk
1 Replies

4. Shell Programming and Scripting

Why stderr file descriptor redirection makes ksh's "select" construct hang.

I am trying to use one global declaration --> "exec 2>$ERR" to capture all stderr outputs that may occur anywhere in my script. Then close it at the end of the script using --> "exec 2<&-" I am using KSH on Solaris 8. KSH Version M-11/16/88i If I comment two "exec .." statements in the... (11 Replies)
Discussion started by: kchinnam
11 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Shell Programming and Scripting

(CSH basic construct) "@" query

While going through a script, i came across few syntax which I am not aware of what they exactly means. @ cnt = 1 @ num_all = `echo $var` What is the significance of "@" here. What is it called? (3 Replies)
Discussion started by: animesharma
3 Replies

7. Solaris

"Estream construct failed" Error on Solaris i86pc

Hi Guys, From past some days, I am getting an error in /var/adm/messages which is as shown below. XXXXX02:/# cat /var/adm/messages |tail Sep 16 15:28:14 XXXX02 EV_AGENT: Agent Main --Estream construct failed. Err: EMULSocket::recv() Sep 16 15:31:49 XXXX02 EV_AGENT: Agent main --... (2 Replies)
Discussion started by: vivek.goel.piet
2 Replies

8. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

9. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
InternetConfig(3)					User Contributed Perl Documentation					 InternetConfig(3)

NAME
Mac::InternetConfig - Interface to Peter Lewis' and Quinns Internet Config system DESCRIPTION
Access to the original Internet Config documentation is essential for proper use of these functions. Constants kICRealName kICEmail kICMailAccount kICMailPassword kICNewsAuthUsername kICNewsAuthPassword kICArchiePreferred kICArchieAll kICUMichPreferred kICUMichAll kICInfoMacPreferred kICInfoMacAll kICPhHost kICWhoisHost kICFingerHost kICFTPHost kICTelnetHost kICSMTPHost kICNNTPHost kICGopherHost kICLDAPServer kICLDAPSearchbase kICWWWHomePage kICWAISGateway kICListFont kICScreenFont kICPrinterFont kICTextCreator kICBinaryTypeCreator kICDownloadFolder kICSignature kICOrganization kICPlan kICQuotingString kICMailHeaders kICNewsHeaders kICMapping kICCharacterSet kICHelper kICServices kICNewMailFlashIcon kICNewMailDialog kICNewMailPlaySound kICNewMailSoundName kICWebBackgroundColour kICNoProxyDomains kICUseSocks kICSocksHost kICUseHTTPProxy kICHTTPProxyHost kICUseFTPProxy kICFTPProxyHost kICFTPProxyUser kICFTPProxyPassword kICFTPProxyAccount Internet Config settings. ICmap_binary ICmap_resource_fork ICmap_data_fork ICmap_post ICmap_not_incoming ICmap_not_outgoing ICservices_tcp ICservices_udp icNoPerm icReadOnlyPerm icReadWritePerm Various constants. Variables $ICInstance The instance of the Internet Config database. %RawInternetConfig Access the raw, uninterpreted value of an Internet Config setting. %InternetConfig Access a sane Perl version of one of the more common Internet Config settings. %InternetConfigMap Access the Internet Config file map to: filename Determine the file type and creator for a newly created file: $map = $InternetConfigMap{"output.html"}; type/creator Determine the extension to use for some type/creator combination: $map = $InternetConfigMap{["WDBN", "MSWD"]}; Types ICMapEntry An entry in the file map. Fields are: short version; OSType file_type; OSType file_creator; OSType post_creator; long flags; Str255 extension; Str255 creator_app_name; Str255 post_app_name; Str255 MIME_type; Str255 entry_name; Functions ICStart ICStart CREATOR Call this at application initialisation. Set creator to your application creator to allow for future expansion of the IC system (Default is MacPerl's creator). Returns a connection to the IC system. ICStop INST It is illegal to call this routine inside a ICBegin/End pair. Call this at application termination, after which INST is no longer valid connection to IC. ICGeneralFindConfigFile INST, SEARCH_PREFS, CAN_CREATE, @FOLDERS ICGeneralFindConfigFile INST, SEARCH_PREFS, CAN_CREATE ICGeneralFindConfigFile INST Mac OS only. It is illegal to call this routine inside a ICBegin/End pair. Call to configure this connection to IC. This routine acts as a more general replacement for ICFindConfigFile and ICFindUserConfigFile. Set search_prefs to 1 (default) if you want it to search the preferences folder. Set can_create to 1 if you want it to be able to create a new config. Set count as the number of valid elements in folders. Set folders to a pointer to the folders to search. Setting count to 0 and folders to nil is OK. Searches the specified folders and then optionally the Preferences folder in a unspecified manner. ICChooseConfig INST Mac OS only. Requires IC 1.2. It is illegal to call this routine inside a ICBegin/End pair. Requests the user to choose a configuration, typically using some sort of modal dialog. If the user cancels the dialog the configuration state will be unaffected. ICChooseNewConfig INST Mac OS only. Requires IC 1.2. It is illegal to call this routine inside a ICBegin/End pair. Requests the user to choose a new configuration, typically using some sort of modal dialog. If the user cancels the dialog the configuration state will be unaffected. ICGetConfigName INST, LONGNAME ICGetConfigName INST Requires IC 1.2. You must specify a configuration before calling this routine. Returns a string that describes the current configuration at a user level. Set longname to 1 if you want a long name, up to 255 characters, or 0 (default) if you want a short name, typically about 32 characters. The returned string is for user display only. If you rely on the exact format of it, you will conflict with any future IC implementation that doesn't use explicit preference files. ICGetConfigReference INST Mac OS only. Requires IC 1.2. You must specify a configuration before calling this routine. Returns a self-contained reference to the instance's current configuration. ICSetConfigReference INST, REF, FLAGS ICSetConfigReference INST, REF Mac OS only. Requires IC 1.2. It is illegal to call this routine inside a ICBegin/End pair. Reconfigures the instance using a configuration reference that was got using ICGetConfigReference reference. Set the icNoUserInteraction_bit in flags if you require that this routine not present a modal dialog. Other flag bits are reserved and should be set to zero. ICGetSeed INST You do not have to specify a configuration before calling this routine. You do not have to be inside an ICBegin/End pair to call this routine. Returns the current seed for the IC prefs database. This seed changes each time a non-volatile preference is changed. You can poll this to determine if any cached preferences change. ICGetComponentInstance INST Mac OS only. Requires IC 1.2. You do not have to specify a configuration before calling this routine. You do not have to be inside an ICBegin/End pair to call this routine. Returns the connection to the IC component. ICBegin INST, PERM You must specify a configuration before calling this routine. It is illegal to call this routine inside a ICBegin/End pair. Starting reading or writing multiple preferences. A call to this must be balanced by a call to ICEnd. Do not call WaitNextEvent between these calls. The perm specifies whether you intend to read or read/write. Only one writer is allowed per instance. Note that this may open resource files that are not closed until you call ICEnd. ICGetPref INST, KEY You must specify a configuration before calling this routine. If you are getting or setting multiple preferences, you should place these calls within an ICBegin/ICEnd pair. If you call this routine outside of such a pair, it implicitly calls ICBegin(inst, icReadOnlyPerm). Reads the preference specified by key from the IC database to the buffer pointed to by buf and size. key must not be the empty string. If called in a scalar context, return the preference. If called in a list context, additionally returns the attributes. Returns icPrefNotFound if there is no preference for the key. ICSetPref INST, KEY, VALUE =item ICSetPref INST, KEY, VALUE, ATTR You must specify a configuration before calling this routine. If you are getting or setting multiple preferences, you should place these calls within an ICBegin/ICEnd pair. If you call this routine outside of such a pair, it implicitly calls ICBegin(inst, icReadWritePerm). Sets the preference specified by KEY from the IC database to the VALUE. If attr is ICattr_no_change (the default) then the preference attributes are not set. Otherwise the preference attributes are set to attr. Returns icPermErr if the previous ICBegin was passed icReadOnlyPerm. Returns icPermErr if current attr is locked, new attr is locked. ICCountPref INST You must specify a configuration before calling this routine. You must be inside an ICBegin/End pair to call this routine. Counts the total number of preferences. ICGetIndPref INST, N You must specify a configuration before calling this routine. You must be inside an ICBegin/End pair to call this routine. Returns the key of the Nth preference. n must be positive. Returns icPrefNotFoundErr if n is greater than the total number of preferences. ICDeletePref INST, KEY You must specify a configuration before calling this routine. You must be inside an ICBegin/End pair to call this routine. Deletes the preference specified by KEY. KEY must not be the empty string. Returns icPrefNotFound if the preference specified by key is not present. ICEnd INST You must specify a configuration before calling this routine. You must be inside an ICBegin/End pair to call this routine. Terminates a preference session, as started by ICBegin. You must have called ICBegin before calling this routine. ICEditPreferences INST, KEY Requires IC 1.1. You must specify a configuration before calling this routine. You do not have to be inside an ICBegin/End pair to call this routine. Instructs IC to display the user interface associated with editing preferences and focusing on the preference specified by key. If key is the empty string then no preference should be focused upon. You must have specified a configuration before calling this routine. You do not need to call ICBegin before calling this routine. In the current implementation this launches the IC application (or brings it to the front) and displays the window containing the preference specified by key. It may have a radically different implementation in future IC systems. ICParseURL INST, HINT, DATA, START, END ICParseURL INST, HINT, DATA Requires IC 1.1. You must specify a configuration before calling this routine. You do not have to be inside an ICBegin/End pair to call this routine. Parses a URL out of the specified text and returns it in a canonical form in a handle. HINT indicates the default scheme for URLs of the form "name@address". If HINT is the empty string then URLs of that form are not allowed. DATA contains the text. START and END should be passed in as the current selection of the text. This selection is given in the same manner as TextEdit, ie if START == END then there is no selection only an insertion point. Also START X END and 0 X START X length(DATA) and 0 X END X length(DATA). If START and END are omitted, the whole of DATA is assumed. In a scalar context, returns URL. In an array context, returns URL, START, END. ICLaunchURL INST, HINT, DATA, START, END ICLaunchURL INST, HINT, DATA Requires IC 1.1. You must specify a configuration before calling this routine. You do not have to be inside an ICBegin/End pair to call this routine. Parses a URL out of the specified text and feeds it off to the appropriate helper. HINT indicates the default scheme for URLs of the form "name@address". If HINT is the empty string then URLs of that form are not allowed. DATA contains the text. START and END should be passed in as the current selection of the text. This selection is given in the same manner as TextEdit, ie if START == END then there is no selection only an insertion point. Also START X END and 0 X START X length(DATA) and 0 X END X length(DATA). If START and END are omitted, the whole of DATA is assumed. In a scalar context, returns URL. In an array context, returns URL, START, END. ICMapFileName INST, NAME Returns the "ICMapEntry" matching best the given name. ICMapTypeCreator INST, TYPE, CREATOR [, NAME] Takes the type and creator (and optionally the name) of an outgoing file and returns the most appropriate "ICMapEntry". ICMapEntriesFileName INST, ENTRIES, NAME Returns the "ICMapEntry" matching best the given name. ICMapEntriesTypeCreator INST, ENTRIES, TYPE, CREATOR [, NAME] Takes the type and creator (and optionally the name) of an outgoing file and returns the most appropriate "ICMapEntry". ICCountMapEntries INST, ENTRIES Counts the number of entries in the map. ICGetIndMapEntry INST, ENTRIES, INDEX Returns the position of a map entry and the entry itself. $map = ICGetIndMapEntry $inst, $entries, 5; ($pos, $map) = ICGetIndMapEntry $inst, $entries, 5; ICGetMapEntry INST, ENTRIES, POS Returns the entry located at position pos in the mappings database. ICSetMapEntry INST, ENTRIES, POS, ENTRY Replace the entry at position pos ICDeleteMapEntry INST, ENTRIES, POS Delete the entry at position pos ICAddMapEntry INST, ENTRIES, ENTRY Add an entry to the database. GetURL URL Launch helper app with URL. Returns undef on error. GetICHelper PROTOCOL Return list of creator ID and name for helper app assigned to PROTOCOL. Returns only creator ID in scalar context. Returns undef on error. AUTHOR
Written by Matthias Ulrich Neeracher <neeracher@mac.com>. Currently maintained by Chris Nandor <pudge@pobox.com>. perl v5.16.2 2013-08-25 InternetConfig(3)
All times are GMT -4. The time now is 02:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy