Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29252 Discussions

bash command operates differently with CALL SYSTEM

Greynolds__Alan
Beginner
773 Views
The following bash command line does what I want:
LCL_ALL=C tr ...
where the ellipsis is just some arguments and IO redirection stuff. However when I issue the exact same command line from my program (compiled with 11.1 on OSX 10.6):
call system("LCL_ALL=C tr ...")
it behaves as if the LCL_ALL=C is absent. Anyone know what's happening here?
Al
0 Kudos
3 Replies
jimdempseyatthecove
Honored Contributor III
773 Views
your system call is creating a local environment (inheriting settings from your program runtime environment)
consider using EXPORT LCL_ALL=C tr...

See: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_02.html

Jim Dempsey
0 Kudos
Greynolds__Alan
Beginner
773 Views
I assume then I'll actually have to do somehting like:

call system("exportLCL_ALL=C && tr ...")

in order or execute the TRanslate command afterwards like my original syntax did.

Al
0 Kudos
TimP
Honored Contributor III
773 Views
Or invoke a shell script which sets the desired shell for itself.
0 Kudos
Reply