Register
It is currently Thu Sep 18, 2014 5:40 am

Variables


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Thu Jun 02, 2011 8:59 am   

Joined: Thu Jun 02, 2011 8:52 am
Posts: 1
Hi all


I'm running stuff with mpi :

#!/bin/bash
BASE='-np 4 my_app --help'
mpiexec "$BASE"


why does this not work?? as I understand variables (from a lot of sources on the net) it should just replace the last line to :

mpiexec -np 4 my_app --help

..but the result is crap :(
is it possible to do this right?

in my final script I have a lot of mpiexec lines, I don't want to write all the arguments (which are much more than in my example) all the time, makes it to difficult to make changes


thanks for reading!

Best regards,

Victor


Top
 Profile  
 PostPosted: Thu Jun 02, 2011 10:29 am   
User avatar

Joined: Sun Jun 27, 2010 12:57 am
Posts: 192
Code:
BASE='-np 4 my_app --help'
The quoting here iis good and will make sure all space separated variables are combined as one string into the variable.

Code:
mpiexec "$BASE"
The quoting here is not good, because this too will combine the contents of the $BASE variable as one string and pass the one string as one parameter to mpiexec. If you remove the double-quotes, the substitution will make sure all space separated content in $BASE will be treated as separate arguments.
Just remove the double quotes and it should work.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP