Shell script inside shell script

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script inside shell script
# 1  
Old 03-21-2014
Shell script inside shell script


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

(snippet of code)
  cat > "$1/$" << EOF
#! /bin/bash
ant -q -buildfile $HOME/$3/build.xml $4

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

Example: has
ant -q -buildfile /root/work/build.xml 2

whereas it should have
ant -q -buildfile $HOME/$3/build.xml $4

Please let me know how to do this?
# 2  
Old 03-21-2014
Use back slash before $
ant -q -buildfile \$HOME/\$3/build.xml \$4

This User Gave Thanks to prav_chidugulla For This Post:
# 3  
Old 03-21-2014
Hi, use quotes around the first EOF
cat > "$1/$" << "EOF"
#! /bin/bash
ant -q -buildfile $HOME/$3/build.xml $4

These 2 Users Gave Thanks to Scrutinizer For This Post:
# 4  
Old 03-21-2014
Thank you prav_chidugulla, i was able to solve the issue.
Thank you Scrutinizer, although i didnot try your way, but thanks for your time..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Capture run time of python script executed inside shell script

I have bash shell script which is internally calling python script.I would like to know how long python is taking to execute.I am not allowed to do changes in python script.Please note i need to know execution time of python script which is getting executed inside shell .I need to store execution... (2 Replies)
Discussion started by: Adfire
2 Replies

2. Shell Programming and Scripting

How to merge Expect script inside shell script?

Hi I have two scripts one is Expect and other is shell. I want to merge Expect code in to Shell script so that i can run it using only one script. Can somebody help me out ? Order to execute: Run first and then when installation completes run shell script. ... (1 Reply)
Discussion started by: ashish_neekhra
1 Replies

3. Shell Programming and Scripting

Nohup inside shell script

Hi, I want to run another script inside shelll script in nohup mode. let explain. under the same folder ,I have two scripts In if then nohup ./ & echo " Script two has been run correctly" else echo " Exiting from the script" fi If... (3 Replies)
Discussion started by: ckchelladurai
3 Replies

4. Shell Programming and Scripting

expect script inside shell script not working.

Shell Scipt: su - <$username> expect pass.exp Expect script: pass.exp #!/usr/bin/expect -f # Login ####################### expect "Password: " send "<$password>\r" it comes up with Password: but doesnt take password passed throguh file. (2 Replies)
Discussion started by: bhavesh.sapra
2 Replies

5. Shell Programming and Scripting

Shell script inside a perl script

How to write a shell script inside a perl script code? It is possible or not. Actually i have a perl script code and i need some values from the shell script code and vice-versa i.e. some values of shell script use by the perl scipt and some values of perl script use by the shell script. So how can... (1 Reply)
Discussion started by: anupdas
1 Replies

6. Shell Programming and Scripting

how to run shell script inside expect script?

I have the code like this : shell script continues ... .... expect -c" spawn telnet $ip expect "login:" send \"$usrname\r\" expect "Password:" send \"$passwd\r\" expect "*\>" send \"$cmdstr\r\" ... (1 Reply)
Discussion started by: robbiezr
1 Replies

7. Shell Programming and Scripting

Call a perl script inside a shell script

Hi all, I have the following snippet of code.. #!/bin/sh echo "run perl script............" #Run the verification script perl bill_ver echo " perl script completed....." echo "rename files......" #Remove from all file in the directories test, test1, test2, test3 for f in... (3 Replies)
Discussion started by: chriss_58
3 Replies

8. Shell Programming and Scripting

invoking a shell script inside cgi shell script

Hi, I have an HTML form through which I get some text as input. i need to run a shell script say inside a perl-cgi script named on the form input. I want to write the contents of the form in a file and then perform some command line operations like grep, cat on the text... (2 Replies)
Discussion started by: smriti_shridhar
2 Replies

9. Shell Programming and Scripting

rlogin inside a c-shell script

Hi Forumers, Sorry if it's really simple, but I couldn't find a way out. :( I've to do something like this in a script (csh): <some commands, variable settings, scripts> rlogin different_server <some commands, variable settings, scripts> After "rlogin", it shows the prompt of the... (5 Replies)
Discussion started by: sumitgarg
5 Replies

10. Shell Programming and Scripting

How to run unix commands in a new shell inside a shell script?

Hi , I am having one situation in which I need to run some simple unix commands after doing "chroot" command in a shell script. Which in turn creates a new shell. So scenario is that - I need to have one shell script which is ran as a part of crontab - in this shell script I need to do a... (2 Replies)
Discussion started by: hkapil
2 Replies
Login or Register to Ask a Question