Need help with a shell script

Discussion in 'Mac Programming' started by thatgreenvw, Nov 30, 2012.

  1. thatgreenvw, Nov 30, 2012
    Last edited by a moderator: Nov 30, 2012

    macrumors newbie

    Joined:
    Nov 29, 2011
    #1
    I'm trying to write a shell script that creates a run script for running an executable. The issue is i'm using variables to assign the job name and number of processors etc contained in the run script, but then within the run script itself it has path name variables which when i run the script get removed since they're not defined higher up.


    Code:
    ###########
    #!/bin/bash
    
    read -p "How many processors? : " PROCNUM
    echo ""
    read -p "What's the jobname? : " NAME
    echo ""
    read -p "What's the walltime? : " WALLTIME
    echo ""
    
    cat <<EOF >run.computer
    #!/bin/bash --login
    #BSUB -n $PROCNUM
    #BSUB -J $NAME
    #BSUB -W $WALLTIME
    
    MYPATH=/home/work/$LSB_JOBNAME
    executable=$MYPATH/executable
    WDPATH=/server/$USER/$LSB_JOBNAME
    
    mkdir -p $WDPATH
    cp $MYPATH/data $WDPATH/
    
    cd $WDPATH
    
    # $LSB_DJOB_NUMPROC is supplied by LSF and is number of processes
    mpirun -np $LSB_DJOB_NUMPROC $executable
    
    EOF
    ##########
    The issue being everything in the cat like path name variables disappear when i run the script. I'm not even sure if using cat is the right way to be going though anyway so any help would be good
     
  2. thread starter macrumors newbie

    Joined:
    Nov 29, 2011
    #2
    Sorted it needed to put a backslash before the necessary dollars
     

Share This Page