creating dynamic shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting creating dynamic shell script
# 1  
Old 02-13-2008
creating dynamic shell script

Hello

I am trying to create a dynamic ksh script and I have an issue.

I have a script a.ksh and it has got the following lines (for example)
Code:
#!/bin/ksh
# trace mode +x : without trace -x : with trace
set +xv
echo hi, i am going to create a dynamic script now
cat >> dynamic.ks <<EOF
#!/bin/ksh
# trace mode +x : without trace -x : with trace
set +xv
###################################################################################################
echo $PATH
ses_exi=$(somefileexcution|grep "somevalue"|wc -1)
if [ "$ses_exi" -eq "1" ]
then 
   echo i can open a new session
else
   echo i cannot open a new session
fi
###################################################################################################
EOF

The dynamic file is getting created but look at the file content, its not the same instead the output of each statement execution. I want the same text that I mention in the code. Any help would be appreciated.

Code:
#!/bin/ksh
# trace mode +x : without trace -x : with trace
set +xv
###################################################################################################
echo /usr/local/bin/ssh:/home/bdrhom01/outils/curl-7.15.1/bin:/etc:/usr/lib:/usr/openwin/bin:/bin:/usr/bin:/usr/sbin:.:/opt/SUNWspro/bin:/usr/ccs/bin:/usr/sfw/bin:/usr/ucb:/usr/local/bin:/bdrhomtt01/oracle/product/10.2.0.3/bin:/home/bdrhom01/ccm_tools:/tools/ccm63/bin:/home/bdrhom01/bin:/home/bdrhom01/outils:/home/bdrhom01
ses_exi=       0
if [ "" -eq "1" ]
then
   echo i can open a new session
else
   echo i cannot open a new session
fi
###################################################################################################

Many thanks in advance
Sundar
# 2  
Old 02-13-2008
Try escaping all $ expressions with a backslash (\). ie, \$ses_exi.
# 3  
Old 02-13-2008
Thanks

Thanks and it works
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Dynamic checkbox(HTML page) for each process using shell script

Hi friends, I m newbie to bash scripting , i m writing script(bash) that will display all processes which r running in my system in an html page, everything going fine but i m not able to get checkbox dynamically for each process in html page ,so that i can mark that process... (2 Replies)
Discussion started by: vagga06
2 Replies

2. Shell Programming and Scripting

Passing dynamic value to shell script

Hi Team, I'm using HP UX. I want to pass a variable dynamically as input while executing the script and that value need to be replaced with a string in the script. I tired SED, in the command line its working but while I keep the same command in the script its not working. Can someone help me... (4 Replies)
Discussion started by: hazel
4 Replies

3. Shell Programming and Scripting

Shell script dynamic command

I need to run a shell script with dynamic command in it like # Begin script... mysql xx "select * from tab" | sed 's/\t/|/g' > GENERATED_20100304.txt the dynamic part is 20100304 which should be today's date, and it needs to run every day and create a new file with... (2 Replies)
Discussion started by: nuthalapati
2 Replies

4. Shell Programming and Scripting

Dynamic SQL query based on shell script parameters

Hi, I need a script that will run a dynamic Oracle SQL. Dynamic meaning the SQL statement depends on the parameter. For instance, something like this: #!/bin/ksh -x # Set environment . /home/mine/set_vars sqlplus $LOGINID <<! >> /home/mine/log.txt select count(1) from $1 where... (2 Replies)
Discussion started by: laiko
2 Replies

5. Shell Programming and Scripting

Creating a dynamic case statement

I'm using the korn shell and trying to create a case statement from the contents of a file that is changed regularly, each line of the file has three fields, eg track1 202.111.111.111 99 room7 222.111.222.333 76 I'm using awk to select each variable. I've been unable to figure out how to... (5 Replies)
Discussion started by: squrcles
5 Replies

6. Shell Programming and Scripting

creating a dynamic array

i want to create an array the array elements are populated depending upon the number of entries present in a data file The data file is created dynamically how to achieve the same thanks (1 Reply)
Discussion started by: trichyselva
1 Replies

7. Shell Programming and Scripting

dynamic editing using shell script

Hi, I would like to edit an input data-file by changing a variable in it in steps: For ex: If my input file is 'big.in', then it has the following data: 2.54 0.01 0.5 0.0 My source code then reads this above line, executes and gives out some output. Then , I want to increment... (1 Reply)
Discussion started by: habzone2007
1 Replies

8. Shell Programming and Scripting

Dynamic variables within shell script

Hi Gurus, I have a requirement of writting the shell script where it should ask me two values FND_TOP=/d02/app/oracle/xxx/fnd/11.5.0 CDCRM_TOP=/d02/app/oracle/xxx/cdcrm/11.5.0 and then keep these values stored as variables for the execution of rest of the script. Because, I have to... (2 Replies)
Discussion started by: isingh786
2 Replies

9. Shell Programming and Scripting

Shell Script Run Interval to be dynamic

Hi All. I have a script which has to be run periodically. The frequency of its run will be decided by a Database stored value PollRate. e.g. If PollRate value is 300secs, then the script should be executed every 5 minutes, if it's 1500secs, it should execute every 15 minutes. Is there... (5 Replies)
Discussion started by: rahulrathod
5 Replies

10. Shell Programming and Scripting

search and replace dynamic data in a shell script

Hi, I have a file that looks something like this: ... 0,6,256,87,0,0,0,1187443420 0,6,438,37,0,0,0,1187443380 0,2,0,0,0,10,0,1197140320 0,3,0,0,0,10,0,1197140875 0,2,0,0,0,23,0,1197140332 0,3,0,0,0,23,0,1197140437 0,2,0,0,0,17,0,1197140447 0,3,0,0,0,17,0,1197140543... (8 Replies)
Discussion started by: csejl
8 Replies
Login or Register to Ask a Question