Sponsored Content
Top Forums Shell Programming and Scripting while puting shell variable in mysql command value does not interpolate Post 302398379 by rrd1986 on Wednesday 24th of February 2010 11:46:25 AM
Old 02-24-2010
Bug while puting shell variable in mysql command value does not interpolate

HTML Code:
 port=$(ssh tms6@$x cat /tms6/scripts/start.lc.sh | grep -P '^\/tms6\/bin\/lc' | cut -d' ' -f3 | cut -b 3-6)
                 tpsip=$(ssh tms6@$x cat /tms6/scripts/start.lc.sh | grep -P '^\/tms6\/bin\/lc' | cut -d' ' -f4 | cut -b 9-)
                 # IFS="\n"
                   set -- $port
                   set -- $tpsip

                 # Converting the string to  array

                 port_arr=( $port )
                 tpsip_arr=( $tpsip )

                 port_num=${#port_arr[@]}
                 tpsip_num=${#tpsip_arr[@]}
          for (( i = 0; i <= $tpsip_num; i++ )) ### Outer for loop ###
            do
               for (( j = $i; j <= $port_num; j++ )) ### Inner for loop ###
                 do
                   # echo -n "${tpsip_arr[$i]}  ${port_arr[$j]}"

                   $MYSQL -u $MyUSER -h $MyHOST -p$MyPASS -D test -Bse 'INSERT INTO LC (server_ip, lc_used_ip, lc_used_port) VALUES ("${BOOT}", "${tpsip_arr[$i]}", "${port_arr[$j]}")'
                   break
                 done
                   echo "" #### print the new line ###
             done
variable marked in red are not interpolating as getting those value in LC table under database 'test' is exactly the same as they appear here.


Plz suggest ny workaround..........
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using variable with cp command in bash shell

Hi, I am trying to write script to copy some files(/ppscdr/cdrp2p/temp/) from one directory to another directory using shell script. see the script below, #!/bin/sh -f dir_name=20061105 mkdir ${dir_name} cd /ppscdr/cdrp2p/temp pwd cp p2p${dir_name}*.*... (4 Replies)
Discussion started by: maheshsri
4 Replies

2. Shell Programming and Scripting

Passing a variable from shell script to mysql query?

I heard this was possible but from my research I haven't been able to figure it out yet. Seems it should be simple enough. Basically from a high level view I'm trying to accomplish... . $X='grep foo blah.log' then 'mysql command SELECT foo FROM bar WHERE ' . $X or something like that. ... (2 Replies)
Discussion started by: kero
2 Replies

3. Shell Programming and Scripting

Not able to store command inside a shell variable, and run the variable

Hi, I am trying to do the following thing var='date' $var Above command substitutes date for and in turn runs the date command and i am getting the todays date value. I am trying to do the same thing as following, but facing some problems, unique_host_pro="sed -e ' /#/d'... (3 Replies)
Discussion started by: gvinayagam
3 Replies

4. Shell Programming and Scripting

Using a shell script variable in a mysql query using 'LIKE'

Hello. I am writing a simple script that reads a text file and removes records from a mysql database. The items in the text file are of the format: firstname.middle.lastXXX, where XXX is a 3 digit number. The table has an email field that will match the firstname.middle.last. So, I thought I... (1 Reply)
Discussion started by: bricoleur
1 Replies

5. Shell Programming and Scripting

mysql script in a command shell

Hi i`m trying this script to run and i get the following error. Enter your name tman Enter your surname smith -bash: ./500: line 20: unexpected EOF while looking for matching `"' -bash: ./500: line 21: syntax error: unexpected end of file ... (2 Replies)
Discussion started by: mduduzi
2 Replies

6. Shell Programming and Scripting

mysql script in a command shell

Hi can anyone help with my issue here. I new in linux and new in scripting. i was ask to do the following below and i`m getting errors. I managed to create the table and the database. Now i need to add the details in a shell to update the database.... (7 Replies)
Discussion started by: mduduzi
7 Replies

7. Shell Programming and Scripting

use shell variable in awk command

Trying to do something like this ls -lrt | awk '$9=="test5"' -rw-r--r-- 1 lrmq db2iadm1 381 Sep 20 21:56 test5 But now, I need to give a variable in place of test5. For example let's define x as test5 x=test5 ls -lrt | awk '$9=="$x"' This doesn't seem to be working. It doesn't take the... (4 Replies)
Discussion started by: blazer789
4 Replies

8. Shell Programming and Scripting

Interpolate a variable with single quotes

I need to interpolate a shell variable in a code, i cannot share the exact code so this is an example i made up to describe the situation What I am trying to do here is try to wrap up the value of a variable in single quotes. This value needs to be passed to another program which would only... (4 Replies)
Discussion started by: sam05121988
4 Replies

9. Shell Programming and Scripting

Interpolate between lines

Dear All, I need your help, I have file like this : input.txt 1000 1002 1006 1010 . . .desired output: 1000 1001 1002 1004 1006 1008 (2 Replies)
Discussion started by: attila
2 Replies
All times are GMT -4. The time now is 10:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy