Include lines within a script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Include lines within a script
# 1  
Old 09-22-2006
Include lines within a script

I want to add lines in my script dynamically.
My script:
...
echo addscript
end addscript
...

Lines to add: (can be put in a file and can be added)
cp /opt/script1.sh opt/script1_org.sh
sed 's/testusr/'${FUNCTID}'/g' /opt/script1.sh > ./tmpfile
mv ./tmpfile /opt/script1.sh
/opt/script1.sh

Actually, I tried and found
sed 's/echo addscript/echo addscript\n\/opt\/script1.sh/' "$fileB" > tmpfile
can add one line. But not able to add multiple lines. I don't want to put \n and do it as if there is a long path for the script directory, it will be pain.

Please help

Thanks
Chiru
# 2  
Old 09-22-2006
Code:
sed "/echo addscript/r script1.sh" file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to include SQL within a script

Hi, I have a script I am developing (actually more than 1 just now). 1st part - executes SQL in a 2nd script. 2nd part - reformats the output of the sql into a csv Problem: How am I able to run the SQL from the first script? I assume there is a sql command? I generally use isql when... (6 Replies)
Discussion started by: mcclunyboy
6 Replies

2. UNIX for Dummies Questions & Answers

[solved] Script creation (how to include options in the script)

Hi guys i have written a script which takes the options given to him and execute itself accordingly. for example if a script name is doctortux then executing doctortux without option should made doctortux to be executed in automatic mode i.e. doctortux -a or if a doctortux is needed to run in... (4 Replies)
Discussion started by: pinga123
4 Replies

3. Shell Programming and Scripting

how to create one newfile and wants include some lines based on user request

I have one request, First it has to create one file and in that file it has to include some lines based on user request. Suppose user requested 10, then script needs to add 10 lines like below QAEVO_A1|A1 QAEVO_A2|A2 QAEVO_A3|A3 QAEVO_A4|A4 QAEVO_A5|A5 QAEVO_A6|A6 QAEVO_A7|A7... (8 Replies)
Discussion started by: sridhusha
8 Replies

4. Shell Programming and Scripting

How to include a command in shell script?

# dbc "delete from alert;" DELETE 10 # However, the script created below generates an error that command does not exits. Can any one please exist. script.sh: #!/bin/sh dbc "delete from alert;" >>$TASKLOGFILE ./script.sh: line 38: dbc: command not found can any one please... (2 Replies)
Discussion started by: sureshcisco
2 Replies

5. UNIX for Dummies Questions & Answers

script/program in vi include $? or...

Hi. When you write a script/program in vi Do you include the $ Eg. #!/bin/bash $ echo "Today's date is `date`" or echo "Today's date is `date`" Make your script executable. $chmod +x script I included that. I keep getting a permission denied... why? Thanks! (5 Replies)
Discussion started by: JudoMan
5 Replies

6. Shell Programming and Scripting

include in script

Hello, I have a script and a second file that contains all parameters needed for the script. How can I include this file in the script ? I tried source but I have a "no such file or directory" error. :) (1 Reply)
Discussion started by: pppswing
1 Replies

7. UNIX for Dummies Questions & Answers

Include PERL script with in the unix shell script

Hi Gurus, Is it possible to include perl script with in the unix shell script? What would be the general syntax? In the above case, is it required to write the below first two lines of codes? #!usr/bin/sh -x #!usr/bin/perl -w Thanks in advance / Mysore Ganapati. (1 Reply)
Discussion started by: ganapati
1 Replies

8. Shell Programming and Scripting

how to include header file in b-sh script

I'm new in this. In C/C++, you define variables in one header file & then simply include it in any files where those variables are referenced. I tried to include a header named DefineVars- which initializes all the globals- but when I add the line "DefineGlobals" at the begining of another... (2 Replies)
Discussion started by: bluemoon1
2 Replies

9. Shell Programming and Scripting

Include xhost + at auto reboot script

Below is the startup/stop script for vncservers by end-user. How can xhost + command include in this script? Please help. Thank you. #!/bin/sh # # Startup/Stop script for vncservers for some users. # case "$1" in 'start') /bin/rm /tmp/.X11-unix/X0 /bin/su - applprod -c... (0 Replies)
Discussion started by: KhawHL
0 Replies

10. Programming

How to include shell script in C program

hi I want to call a shell script in C program the script is : ssh -t user@remote sh /<remote>home/user/<file_name>.sh and other several commands C program : Call this script and the retrive the task that is been done in <file_name>.sh file can any one tell me how... (5 Replies)
Discussion started by: mridula
5 Replies
Login or Register to Ask a Question