Error executing a variable

greetings,

i'll try to keep this simple...
i have a script that sets up my environment and creates a command line variable to execute. when i execute the variable i get an error telling me it cannot open one of the files on the command line. the error prints a file name that is definitely available for open. however, if i echo the variable and copy/paste the value it returns the command executes fine.

any suggestions? thanks.

Can you supply the example/output?

Can you be more specific. Show us what you are doing. How have you defined the variable? How are you executing it? Show both cases.

contents of $LMSDB_FILE:

-host t70cfd176 -n 12 -envall -env OMP_NUM_THREADS 1 -wdir "/cadhome/analysis/username/lms_example1/" "/usr/apps/LMS/12/Sysnoise/Lms/XPR.R12/Sysnoise/5.6/bin/sysnoise" -m6.125p -if "/cadhome/analysis/username/lms_example1/3906717-CommandFile.cmd" -of "/cadhome/analysis/username/lms_example1/3906717-sysnoise.log"

contents of $SH_FILE:

export OMP_NUM_THREADS=1;
cd "/cadhome/analysis/username/lms_example1/";
"/usr/apps/LMS/12/Sysnoise/Lms/XPR.R12/Sysnoise/5.6/bin/sysnoise" -hf "/cadhome/analysis/username/lms_example1/3906717-hostfile.LMSVldb" -parallelism frequency
export ver="12"
export EXE="/usr/apps/LMS/$ver/Sysnoise/Lms/XPR.R$ver/Sysnoise/5.6/bin/sysnoise"
export CMD_LINE="$EXE `cat $LMSDB_FILE` `cat $SH_FILE.orig | tail -1 | awk '{print $4, $5, $6}'`"

i then enter $CMD_LINE at the prompt and get the following error:

-ERR> Cannot open file "/cadhome/analysis/username/lms_example1/3906717-CommandFile.cmd" for input
-ERR> InitOSLevel2 failed...

and that file can be listed via the output of the error.

---------- Post updated at 11:31 AM ---------- Previous update was at 11:19 AM ----------

the error is referring to the file name that is supplied to the -hf command line option in the $LMSDB_FILE file.

The first thing I would do is take the double quotes off of the contents of $SH_FILE:

export OMP_NUM_THREADS=1;
cd /cadhome/analysis/username/lms_example1/
/usr/apps/LMS/12/Sysnoise/Lms/XPR.R12/Sysnoise/5.6/bin/sysnoise -hf /cadhome/analysis/username/lms_example1/3906717-hostfile.LMSVldb -parallelism frequency

and I don't think they're needed in $LMSDB_FILE either.

i could certainly do that but the only thing i'm taking from that file are the last few arguments on the last line of the file via tail and awk. i should have posted the CMD_LINE value:

/usr/apps/LMS/12/Sysnoise/Lms/XPR.R12/Sysnoise/5.6/bin/sysnoise -host t70cfd176 -n 12 -envall -env OMP_NUM_THREADS 1 -wdir "/cadhome/analysis/username/lms_example1/" "/usr/apps/LMS/12/Sysnoise/Lms/XPR.R12/Sysnoise/5.6/bin/sysnoise" -m6.125p -if "/cadhome/analysis/username/lms_example1/3906717-CommandFile.cmd" -of "/cadhome/analysis/username/lms_example1/999999-sysnoise.log" -parallelism frequency

I think the reason it is failing is because the directory string is enclosed in double quotes in the variable CMD_LINE and it has to do with the way the shell sees this when you try to execute it as a variable.

1 Like

port43,
i'll admit i thought you were all wet but not to ignore any suggestion when asking i ran $SH_FILE and $LMSDB_FILE through sed and stripped all the quotes out. so the end result was a quote free $CMD_LINE variable and wouldn't you know it, it worked!

i never gave those quotes a second thought since they're supplied to me via some GUI as setup files for a hand run calculation. i just took from them what i thought i needed and made a CMD_LINE variable to execute. knowing up front they weren't needed i should have just took them out but i never thought they'd be an issue. remind me to never doubt you again! thanx for the help!!
joe.