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

Similar Threads
thread Thread Starter Forum Replies Last Post
Apple script batch shell script prramesh Mac Programming 5 Sep 15, 2013 03:35 AM
AudioScope.sh shell script... wisecracker MacBook Pro 0 Jul 31, 2013 01:31 PM
Anyone know how to use AppleScript or shell-script? gba2000 Mac Applications and Mac App Store 0 Apr 23, 2013 11:14 AM
How to create a shell script and run it? Killwin98 Mac Programming 3 Mar 18, 2013 06:39 PM
How to show progress when use do shell script? mikezang Mac Programming 2 Aug 27, 2012 09:54 PM

Forum Jump

All times are GMT -5. The time now is 01:07 PM.

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

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