odd behaviour with quoted input strings

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting odd behaviour with quoted input strings
# 1  
Old 01-29-2008
odd behaviour with quoted input strings

I'm working with a java-based monitoring tool (Solaris/x86) which can be configured to call a shell script when a particular event occurs. The java app sends a set of quoted strings as input to the shell script.

The problem I'm running into is that the shell script, when called by the java app, appears to be treating the quote marks as if they are escaped.

Here's a simplified example of what I'm seeing.

$ cat myscript.sh

echo p1 = .$p1.
echo p2 = .$p2.
echo p3 = .$p3.
echo p4 = .$p4.
# end of myscript.sh

If I manually run myscript.sh with a couple quoted input strings I get the desired behaviour, namely p1 and p2 are set to the value of the 2 input strings, while p3 and p4 are undefined/empty:

$ myscript.sh 'a b' 'c d'
p1 = .a b.
p2 = .c d.
p3 = ..
p4 = ..

When the java app calls myscript.sh with the same quoted string arguments I do not get the desired results:

p1 = .'a.
p2 = .b'.
p3 = .'c.
p4 = .d'.

Besides the fact that the p[1-4] variables have the wrong values, there's the oddity that the quotes are showing up as part of the values stored in the p[1-4] variables.

I've modified myscript.sh to run 'env|sort' and 'stty -a' and then compared the 2 sets of output (my manual run vs java app's run). I've reconfigured my environment to use the same settings as the java app, but so far have not been able to duplicate the results obtained when the java app calls myscript.sh.

I've also made sure that the java app and I are running under the same UNIX login ... still a no go.

The java app does not exhibit this behaviour on other UNIX machines so I'm assuming/hoping this is a 'simple' issue of an environment setting for the java app on this machine, but at the moment I'm drawing a blank.

Any suggestions/ideas?

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Python or Shell script to Grep strings from input file and output in csv format

Hi Experts, I am writing a python script to grep string from file and display output in csv file as in attached screenshot https://drive.google.com/file/d/1gfUUdfmQma33tz65NskThYDhkZUGQO0H/view Input file(result_EPFT_config_device) Below is the python script i have prepared as of... (1 Reply)
Discussion started by: as7951
1 Replies

2. Shell Programming and Scripting

Odd Behaviour for Set and IFS variable

Ok, so I'm playing around with delimters and reading files. and I came across this behaviour that I thought was a bit odd, regarding how the set command takes values... If I run this: IFS=$'-' #Assigns the - as the default delimiter for bash set I-love-my-gf-a-lot #uses set to put a bunch of... (1 Reply)
Discussion started by: Lost in Cyberia
1 Replies

3. Shell Programming and Scripting

Odd behaviour with Expect password update script

Hi there. I've been forced by circumstance to write an expect script to handle password updates on a number of servers. There's a mix of Solaris 8, 9, 10, RedHat and Ubuntu. There's no chance the client will allow us to hook them up to a directory, so we have to make do. This script is mostly... (0 Replies)
Discussion started by: whetu
0 Replies

4. Shell Programming and Scripting

create an array which can store the strings from the user input in shell script

I want to create an array which can store the strings from the user input in shell script . example :- I want to store the 5 fruits name in a single array which the user provides . (1 Reply)
Discussion started by: Pkast
1 Replies

5. Shell Programming and Scripting

awk? extract quoted "" strings from multiple lines.

I am trying to extract multiple strings from snmp-mib files like below. ----- $ cat IF-MIB.mib <snip> linkDown NOTIFICATION-TYPE OBJECTS { ifIndex, ifAdminStatus, ifOperStatus } STATUS current DESCRIPTION "A linkDown trap signifies that the SNMP entity, acting in... (5 Replies)
Discussion started by: genzo
5 Replies

6. Shell Programming and Scripting

Take quoted output from one script as quoted input for another script

Hi, I have a script output.sh which produces the following output (as an example): "abc def" "ghi jkl" This output should be handled from script input.sh as input and the quotes should be treated as variable delimiters but not as regular characters. input.sh (processing positional... (2 Replies)
Discussion started by: stresing
2 Replies

7. Shell Programming and Scripting

Convert CSV file (with double quoted strings) to pipe delimited file

Hi, could some help me convert CSV file (with double quoted strings) to pipe delimited file: here you go with the same data: 1,Friends,"$3.99 per 1,000 listings",8158here " 1,000 listings " should be a single field. Thanks, Ram (8 Replies)
Discussion started by: Ram.Math
8 Replies

8. Shell Programming and Scripting

Script that takes strings as input

Hello all! I need to take a series of inputs passed to one shell script and pass them to a second shell script. For example, the first shell script, script_one.sh, has the following inputs: ./script_one -u username -p password -option1 string1 -option2 -string2 ....Inside of script_one.sh... (4 Replies)
Discussion started by: bashnewbee
4 Replies

9. Solaris

odd behaviour of app writes to mirrored volumes

Hi, Normally, I setup my volumes under Solaris (doesnt matter, 8 or 10), as vxassist -g dg01 -U gen make vol01 500m dg0101, then I do a mirror vxassist -g dg01 mirror vol01 dg0102. Which is legal and does work, however, when the primary dg01 array (or simply in this case, the volume)... (2 Replies)
Discussion started by: mrmurdock
2 Replies

10. Shell Programming and Scripting

awk search for Quoted strings (')

Hi All, I have files: 1. abc.sql 'This is a sample file for testing' This does not have quotations this also does not have quotations. and this 'has quotations'. here I need to list the hard coded strings 'This is a sample file for testing' and 'has quotations'. So i have... (13 Replies)
Discussion started by: kprattip
13 Replies
Login or Register to Ask a Question