Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Nov 30, 2012, 07:26 AM   #1
thatgreenvw
macrumors newbie
 
Join Date: Nov 2011
Need help with a shell script

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

Last edited by OllyW; Nov 30, 2012 at 10:22 AM. Reason: Please use code tags
thatgreenvw is offline   0 Reply With Quote
Old Nov 30, 2012, 07:55 AM   #2
thatgreenvw
Thread Starter
macrumors newbie
 
Join Date: Nov 2011
Sorted it needed to put a backslash before the necessary dollars
thatgreenvw is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:24 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC