Sponsored Content
Top Forums Shell Programming and Scripting [bash] command line substitution with environmental variables Post 302401387 by ASGR on Friday 5th of March 2010 11:41:55 PM
Old 03-06-2010
[bash] command line substitution with environmental variables

Hi,

I'm using an array that contains compiler FLAGS
that need to be executed either before ./configure
or after the main 'make' command.

example of array containing compiler flags.
-------------------------------------------------
Code:
FLAGS[0]="CFLAGS=\"-arch x86_64 -g -Os -pipe -no-cpp-precomp\""
FLAGS[1]="LDFLAGS=\"-arch x86_64 -bind_at_load\""

To get the output:
CFLAGS="-arch x86_64 -g -Os -pipe -no-cpp-precomp" LDFLAGS="-arch x86_64 -bind_at_load" ./configure

Unfortunately, when I try to use the usual substitution
$(${FLAGS[@]}), it seems to terminate after the first
space following the -arch option:

CFLAGS="-arch: command not found

I've tried a number of combinations but not been able
to find a conclusive solution. Any help or ideas would
be appreciated.

A.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Environmental Variables - where stored ?

Hi all ! Yesterday I defined an environmental variable PATH, but today when I restarted machine, I could not see that it was stored any place. Is there any file where I could save the settings ? I have quite a few env.variables defined, so I need a smarter way to define. regards D (5 Replies)
Discussion started by: DGoubine
5 Replies

2. UNIX for Dummies Questions & Answers

Unix passing environmental Variables

In my script when I change an env variable in the parent shell it is only changed for that session - it there away to change it permanently using a script so that when I use rlogin (create a child session) that the env variable is set correctly? Basically what I am trying to do is to pass a... (7 Replies)
Discussion started by: belfastbelle
7 Replies

3. AIX

Best way to setup my own environmental variables ?

I am writing a few korn scripts to be used by all our operators on several 4.1/4.2 AIX servers. I want to create environmental variables that once set, can be read/modified by my scripts (ex: specific folders, file names, conventions, general values, ...). I thought this would be better then... (4 Replies)
Discussion started by: Browser_ice
4 Replies

4. Shell Programming and Scripting

Oracle environmental variables in shells script

Hi, Getting below error on executing the shell script which initiates sqlplus How to set oracle enviornment variables in the shell script ? With Regards (3 Replies)
Discussion started by: milink
3 Replies

5. Shell Programming and Scripting

bash, command line substitution

I have one script calling another with a set of strings that includes white space. Script A calls Script B with these input strings: one two "th ree" Script B pulls apart the arguments correctly: arg0 = one, arg1 = two, arg2 = "th ree" if I call it from within Script A like so:... (10 Replies)
Discussion started by: skippyV
10 Replies

6. Shell Programming and Scripting

Help with manipulating environmental variables in UNIX

I am wondering if there is away to increment a date in c shell. What I need to do is basic, but I lack the knowledge. I have they following environmental variable in my job scripts setenv YYYY `date '+%Y'` I then set YYYY to be part of my output dataset name: setenv dd_OUTPUTP... (1 Reply)
Discussion started by: jclanc8
1 Replies

7. OS X (Apple)

Don't understand the practical difference between command aliases and environmental variables

Hey, I'm recently learning Unix from the video course by Kevin Scoglund. I'm stuck at the moment where he goes into Environmenat variables. I have some issues with understanding what's the essential difference between EV and command aliases: for instance, by writing the command alias ll='ls... (3 Replies)
Discussion started by: scrutinizerix
3 Replies

8. Shell Programming and Scripting

How to Force command substitution evaluation in bash?

OK, I'm striving to abide by all the rules this time. Here is a fragment of my windows10/cygwin64/bash script: export BUPLOG=$(BackupRecords --log "$src") robocopy $(BackupRecords -mrbd "$src" --path "$src") $(BackupRecords --appSwitches "$src") "$src" "$dst" $(BackupRecords --fileSwitches... (0 Replies)
Discussion started by: siegfried
0 Replies

9. Shell Programming and Scripting

How to Force command substitution evaluation in bash?

OK, I'm striving to abide by all the rules this time. Here is a fragment of my windows10/cygwin64/bash script: export BUPLOG=$(BackupRecords --log "$src") robocopy $(BackupRecords -mrbd "$src" --path "$src") $(BackupRecords --appSwitches "$src") "$src" "$dst" $(BackupRecords --fileSwitches... (15 Replies)
Discussion started by: siegfried
15 Replies

10. Shell Programming and Scripting

<< Environmental Variables are not set when script completes >>

Hi Team, I have a wrapper script which i have pasted below, it internally calls one python script to generate Environmental in a file called /home/oracle/myenv.sh, when i execute this script via wrapper script, its not reflecting in my current session, still showing old env variables. any... (2 Replies)
Discussion started by: kamauv234
2 Replies
ortecc(1)							     Open MPI								 ortecc(1)

NAME
ortecc -- OpenRTE C wrapper compiler SYNTAX
ortecc [-showme|-showme:compile|-showme:link] ... OPTIONS
-showme Do not invoke the underlying compiler. Instead, show the command line that would be executed to compile the program. NOTE: If a non-filename argument is passed on the command line, the -showme option will not display any additional flags. For example, both "ortecc --showme" and "ortecc --showme my_source.c" will show all the wrapper-supplied flags. But "ortecc -showme -v" will only show the underlying compiler name and "-v". -showme:compile Do not invoke the underlying C compiler. Instead, show the compiler flags that would be supplied to the C compiler. -showme:link Do not invoke the underlying C compiler. Instead, show the linker flags that would be supplied to the C compiler. See the man page for your underlying compiler for other options that can be passed through ortecc DESCRIPTION
Conceptually, the role of these commands is quite simple: transparently add relevant compiler and linker flags to the user's command line that are necessary to compile / link OpenRTE programs, and then invoke the underlying compiler to actually perform the command. As such, these commands are frequently referred to as "wrapper" compilers because they do not actually compile or link applications them- selves; they only add in command line flags and invoke the back-end compiler. Background Open MPI is comprised of three software layers: OPAL (Open Portable Access Layer), ORTE (Open Run-Time Environment), and OMPI (Open MPI). There are wrapper compilers for each layer; each layer's wrapper only links in the libraries relevant for that layer. Specifically, each layer provides the following wrapper compilers: OPAL opalcc and opalc++ ORTE ortecc and ortec++ OMPI mpicc, mpic++, mpicxx, mpiCC (only on systems with case-senstive file systems), mpif77, and mpif90. Note that mpic++, mpicxx, and mpiCC all invoke the same underlying C++ compiler with the same options. All are provided as compatibility with other MPI implementa- tions. The Fortran wrapper compilers for MPI (mpif77 and mpif90) will be inoperative and will return an error on use if Fortran 77 / Fortran 90 support was not built into the MPI layer. Overview ortecc is a convenience wrappers for the underlying C compiler. Translation of an OpenRTE program requires the linkage of the OpenRTE-spe- cific libraries which may not reside in one of the standard search directories of ld(1). It also often requires the inclusion of header files what may also not be found in a standard location. ortecc passes its arguments to the underlying C compiler along with the -I, -L and -l options required by OpenRTE programs. The OpenRTE Team strongly encourages using the wrapper compilers instead of attempting to link to the OpenRTE libraries manually. This allows the specific implementation of OpenRTE to change without forcing changes to linker directives in users' Makefiles. Indeed, the spe- cific set of flags and libraries used by the wrapper compilers depends on how OpenRTE was configured and built; the values can change between different installations of the same version of OpenRTE. Indeed, since the wrappers are simply thin shells on top of an underlying compiler, there are very, very few compelling reasons not to use ortecc. When it is not possible to use the wrappers directly, the -showme:compile and -showme:link options should be used to determine what flags the wrappers would have used. For example: shell$ cc -c file1.c `mpicc -showme:compile` shell$ cc -c file2.c `mpicc -showme:compile` shell$ cc file1.o file2.o `mpicc -showme:link` -o my_mpi_program NOTES
It is possible to make the wrapper compilers multi-lib aware. That is, the libraries and includes specified may differ based on the com- piler flags specified (for example, with the GNU compilers on Linux, a different library path may be used if -m32 is seen versus -m64 being seen). This is not the default behavior in a standard build, but can be activated (for example, in a binary package providing both 32 and 64 bit support). More information can be found at: https://svn.open-mpi.org/trac/ompi/wiki/compilerwrapper3264 FILES
The string that the wrapper compilers insert into the command line before invoking the underlying compiler are stored in a text file cre- ated by OpenRTE and installed to $pkgdata/ortecc-wrapper-data.txt, where $pkgdata is typically $prefix/share/openmpi, and $prefix is the top installation directory of OpenRTE. It is rarely necessary to edit this file, but it can be examined to gain insight into what flags the wrappers are placing on the command line. ENVIRONMENT VARIABLES
By default, the wrappers use the compilers that were selected when OpenRTE was configured. These compilers were either found automatically by Open MPI's "configure" script, or were selected by the user in the CC, CXX, F77, and/or FC environment variables before "configure" was invoked. Additionally, other arguments specific to the compiler may have been selected by configure. These values can be selectively overridden by either editing the text files containing this configuration information (see the FILES sec- tion), or by setting selected environment variables of the form "ORTE_value". Valid value names are: CPPFLAGS Flags added when invoking the preprocessor (C or C++) LDFLAGS Flags added when invoking the linker (C, C++, or Fortran) LIBS Libraries added when invoking the linker (C, C++, or Fortran) CC C compiler CFLAGS C compiler flags CXX C++ compiler CXXFLAGS C++ compiler flags F77 Fortran 77 compiler FFLAGS Fortran 77 compiler flags FC Fortran 90 compiler FCFLAGS Fortran 90 compiler flags 1.4.5 Feb 10, 2012 ortecc(1)
All times are GMT -4. The time now is 02:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy