Shell script inside shell script

Hi,

I am trying to create a shell script b.sh inside a shell script a.sh. Now, I need to execute the command inside b.sh on another server and pick the values of that server. But i am unable to do the same.

(snippet of code)

Code:
  cat > "$1/$2.sh" << EOF
#! /bin/bash
ant -q -buildfile $HOME/$3/build.xml $4

Now what I need is when b.sh is created, it should have the same text inside it. But what is happening is it is replacing $HOME , $3 and $4 when a.sh is executed.

Example:
b.sh has[/code]
ant -q -buildfile /root/work/build.xml 2
[/code]
whereas it should have
Code:
ant -q -buildfile $HOME/$3/build.xml $4
So that when b.sh is executed on some other server, it picks the values from that server.

Please let me know how to do this?
 
You need to escape the $ to prevent the shell from interpreting the variables.

Code:
    ant -q -buildfile \$HOME/\$3/build.xml \$4

Also note that /bin/bash doesn't exist, you're not on Linux. Use /bin/sh.
 
Back
Top