passing variable through cat EOF command with for loop












1















How do I get the script run with the sbatch command to run with the 23 individual run_prep_chem_$dd.sh (i.e. run_prep_chem_08.sh...run_prep_chem_30.sh)? I am thinking since its in this for loop that it would run properly. The code above the sbatch loops through 23 times but not the at sbatch script line



#!/bin/bash

RP_INPUT='$RP_INPUT'
END='$END'

for dd in {08..30}; do

set dd=$dd

printf "%-3s %02dn" "$dd" "$((10#$dd + 1))"

cat > /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/PREP_FILES/prep_chem_sources_$dd.inp << __EOF
$RP_INPUT

!---------------- grid_type of the grid output
grid_type= 'mercator',
!'rams' = rams grid
! 'polar' = polar sterog. grid output
! 'gg' = gaussian grid output
! 'll' = lat/lon grid output
! 'lambert' = lambert grid output
! 'mercator' = mercator grid output

!---------------- if the output data is for use in CATT-BRAMS model, provide at least one analysis file

$END

__EOF

cp /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/PREP_FILES/prep_chem_sources_$dd.inp /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/prep_chem_sources.inp

cat > /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/PREP_FILES/run_prep_chem_$dd.sh << BEOF
#!/bin/bash -x
#SBATCH --ntasks=1
#SBATCH --mem-per-cpu=100000
#SBATCH --cpus-per-task=1
#SBATCH --time=00:30:00
export I_MPI_JOB_STARTUP_TIMEOUT=10000

source /etc/bashrc

module load hdf5/1.8.12

srun --distribution=block:block /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/prep_chem_sources_RADM_WRF_FIM.exe

BEOF

chmod 757 /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/PREP_FILES/run_prep_chem_$dd.sh

mv /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/PREP_FILES/run_prep_chem_$dd.sh /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/run_prep_chem_$dd.sh

sbatch --dependency=afterok:$SLURM_JOB_ID /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/run_prep_chem_$dd.sh

cp /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/AEROSE_APRIL_CTL-T-2010-04-$dd-000000-g1-ab.bin /data/users/jwsmith/WRFV3/run/AEROSE_APRIL_CTL-T-2010-04-$dd-000000-g1-ab.bin

done









share|improve this question

























  • What is sbatch? What happens in that line? Is there an error? Is the rest of the script irrelevant to this problem? If so why do you give us all that code? You should minimize the code to that necessary to reproduce the problem.

    – Hauke Laging
    Nov 3 '14 at 0:22











  • what is the set dd=$dd supposed to do? If you think that that will export the dd variable, you're wrong. put an export dd at the top of your script for that. I cannot test or answer since I don't have those (gdal?) tools installed on this machine and there may be other problems with your script.

    – pizdelect
    Jan 11 at 13:17


















1















How do I get the script run with the sbatch command to run with the 23 individual run_prep_chem_$dd.sh (i.e. run_prep_chem_08.sh...run_prep_chem_30.sh)? I am thinking since its in this for loop that it would run properly. The code above the sbatch loops through 23 times but not the at sbatch script line



#!/bin/bash

RP_INPUT='$RP_INPUT'
END='$END'

for dd in {08..30}; do

set dd=$dd

printf "%-3s %02dn" "$dd" "$((10#$dd + 1))"

cat > /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/PREP_FILES/prep_chem_sources_$dd.inp << __EOF
$RP_INPUT

!---------------- grid_type of the grid output
grid_type= 'mercator',
!'rams' = rams grid
! 'polar' = polar sterog. grid output
! 'gg' = gaussian grid output
! 'll' = lat/lon grid output
! 'lambert' = lambert grid output
! 'mercator' = mercator grid output

!---------------- if the output data is for use in CATT-BRAMS model, provide at least one analysis file

$END

__EOF

cp /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/PREP_FILES/prep_chem_sources_$dd.inp /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/prep_chem_sources.inp

cat > /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/PREP_FILES/run_prep_chem_$dd.sh << BEOF
#!/bin/bash -x
#SBATCH --ntasks=1
#SBATCH --mem-per-cpu=100000
#SBATCH --cpus-per-task=1
#SBATCH --time=00:30:00
export I_MPI_JOB_STARTUP_TIMEOUT=10000

source /etc/bashrc

module load hdf5/1.8.12

srun --distribution=block:block /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/prep_chem_sources_RADM_WRF_FIM.exe

BEOF

chmod 757 /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/PREP_FILES/run_prep_chem_$dd.sh

mv /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/PREP_FILES/run_prep_chem_$dd.sh /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/run_prep_chem_$dd.sh

sbatch --dependency=afterok:$SLURM_JOB_ID /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/run_prep_chem_$dd.sh

cp /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/AEROSE_APRIL_CTL-T-2010-04-$dd-000000-g1-ab.bin /data/users/jwsmith/WRFV3/run/AEROSE_APRIL_CTL-T-2010-04-$dd-000000-g1-ab.bin

done









share|improve this question

























  • What is sbatch? What happens in that line? Is there an error? Is the rest of the script irrelevant to this problem? If so why do you give us all that code? You should minimize the code to that necessary to reproduce the problem.

    – Hauke Laging
    Nov 3 '14 at 0:22











  • what is the set dd=$dd supposed to do? If you think that that will export the dd variable, you're wrong. put an export dd at the top of your script for that. I cannot test or answer since I don't have those (gdal?) tools installed on this machine and there may be other problems with your script.

    – pizdelect
    Jan 11 at 13:17
















1












1








1








How do I get the script run with the sbatch command to run with the 23 individual run_prep_chem_$dd.sh (i.e. run_prep_chem_08.sh...run_prep_chem_30.sh)? I am thinking since its in this for loop that it would run properly. The code above the sbatch loops through 23 times but not the at sbatch script line



#!/bin/bash

RP_INPUT='$RP_INPUT'
END='$END'

for dd in {08..30}; do

set dd=$dd

printf "%-3s %02dn" "$dd" "$((10#$dd + 1))"

cat > /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/PREP_FILES/prep_chem_sources_$dd.inp << __EOF
$RP_INPUT

!---------------- grid_type of the grid output
grid_type= 'mercator',
!'rams' = rams grid
! 'polar' = polar sterog. grid output
! 'gg' = gaussian grid output
! 'll' = lat/lon grid output
! 'lambert' = lambert grid output
! 'mercator' = mercator grid output

!---------------- if the output data is for use in CATT-BRAMS model, provide at least one analysis file

$END

__EOF

cp /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/PREP_FILES/prep_chem_sources_$dd.inp /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/prep_chem_sources.inp

cat > /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/PREP_FILES/run_prep_chem_$dd.sh << BEOF
#!/bin/bash -x
#SBATCH --ntasks=1
#SBATCH --mem-per-cpu=100000
#SBATCH --cpus-per-task=1
#SBATCH --time=00:30:00
export I_MPI_JOB_STARTUP_TIMEOUT=10000

source /etc/bashrc

module load hdf5/1.8.12

srun --distribution=block:block /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/prep_chem_sources_RADM_WRF_FIM.exe

BEOF

chmod 757 /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/PREP_FILES/run_prep_chem_$dd.sh

mv /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/PREP_FILES/run_prep_chem_$dd.sh /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/run_prep_chem_$dd.sh

sbatch --dependency=afterok:$SLURM_JOB_ID /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/run_prep_chem_$dd.sh

cp /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/AEROSE_APRIL_CTL-T-2010-04-$dd-000000-g1-ab.bin /data/users/jwsmith/WRFV3/run/AEROSE_APRIL_CTL-T-2010-04-$dd-000000-g1-ab.bin

done









share|improve this question
















How do I get the script run with the sbatch command to run with the 23 individual run_prep_chem_$dd.sh (i.e. run_prep_chem_08.sh...run_prep_chem_30.sh)? I am thinking since its in this for loop that it would run properly. The code above the sbatch loops through 23 times but not the at sbatch script line



#!/bin/bash

RP_INPUT='$RP_INPUT'
END='$END'

for dd in {08..30}; do

set dd=$dd

printf "%-3s %02dn" "$dd" "$((10#$dd + 1))"

cat > /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/PREP_FILES/prep_chem_sources_$dd.inp << __EOF
$RP_INPUT

!---------------- grid_type of the grid output
grid_type= 'mercator',
!'rams' = rams grid
! 'polar' = polar sterog. grid output
! 'gg' = gaussian grid output
! 'll' = lat/lon grid output
! 'lambert' = lambert grid output
! 'mercator' = mercator grid output

!---------------- if the output data is for use in CATT-BRAMS model, provide at least one analysis file

$END

__EOF

cp /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/PREP_FILES/prep_chem_sources_$dd.inp /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/prep_chem_sources.inp

cat > /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/PREP_FILES/run_prep_chem_$dd.sh << BEOF
#!/bin/bash -x
#SBATCH --ntasks=1
#SBATCH --mem-per-cpu=100000
#SBATCH --cpus-per-task=1
#SBATCH --time=00:30:00
export I_MPI_JOB_STARTUP_TIMEOUT=10000

source /etc/bashrc

module load hdf5/1.8.12

srun --distribution=block:block /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/prep_chem_sources_RADM_WRF_FIM.exe

BEOF

chmod 757 /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/PREP_FILES/run_prep_chem_$dd.sh

mv /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/PREP_FILES/run_prep_chem_$dd.sh /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/run_prep_chem_$dd.sh

sbatch --dependency=afterok:$SLURM_JOB_ID /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/run_prep_chem_$dd.sh

cp /data/users/jwsmith/PREP-CHEM-SRC-1.4/bin/AEROSE_APRIL_CTL-T-2010-04-$dd-000000-g1-ab.bin /data/users/jwsmith/WRFV3/run/AEROSE_APRIL_CTL-T-2010-04-$dd-000000-g1-ab.bin

done






bash variable for






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 11 at 11:31









Kusalananda

124k16234385




124k16234385










asked Nov 2 '14 at 23:12









Jonathan Smith - NOAA AffiliatJonathan Smith - NOAA Affiliat

61




61













  • What is sbatch? What happens in that line? Is there an error? Is the rest of the script irrelevant to this problem? If so why do you give us all that code? You should minimize the code to that necessary to reproduce the problem.

    – Hauke Laging
    Nov 3 '14 at 0:22











  • what is the set dd=$dd supposed to do? If you think that that will export the dd variable, you're wrong. put an export dd at the top of your script for that. I cannot test or answer since I don't have those (gdal?) tools installed on this machine and there may be other problems with your script.

    – pizdelect
    Jan 11 at 13:17





















  • What is sbatch? What happens in that line? Is there an error? Is the rest of the script irrelevant to this problem? If so why do you give us all that code? You should minimize the code to that necessary to reproduce the problem.

    – Hauke Laging
    Nov 3 '14 at 0:22











  • what is the set dd=$dd supposed to do? If you think that that will export the dd variable, you're wrong. put an export dd at the top of your script for that. I cannot test or answer since I don't have those (gdal?) tools installed on this machine and there may be other problems with your script.

    – pizdelect
    Jan 11 at 13:17



















What is sbatch? What happens in that line? Is there an error? Is the rest of the script irrelevant to this problem? If so why do you give us all that code? You should minimize the code to that necessary to reproduce the problem.

– Hauke Laging
Nov 3 '14 at 0:22





What is sbatch? What happens in that line? Is there an error? Is the rest of the script irrelevant to this problem? If so why do you give us all that code? You should minimize the code to that necessary to reproduce the problem.

– Hauke Laging
Nov 3 '14 at 0:22













what is the set dd=$dd supposed to do? If you think that that will export the dd variable, you're wrong. put an export dd at the top of your script for that. I cannot test or answer since I don't have those (gdal?) tools installed on this machine and there may be other problems with your script.

– pizdelect
Jan 11 at 13:17







what is the set dd=$dd supposed to do? If you think that that will export the dd variable, you're wrong. put an export dd at the top of your script for that. I cannot test or answer since I don't have those (gdal?) tools installed on this machine and there may be other problems with your script.

– pizdelect
Jan 11 at 13:17












0






active

oldest

votes











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f165607%2fpassing-variable-through-cat-eof-command-with-for-loop%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f165607%2fpassing-variable-through-cat-eof-command-with-for-loop%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to make a Squid Proxy server?

Is this a new Fibonacci Identity?

19世紀