Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


Closed Thread
  Search this Thread
Old 03-14-2008, 06:37 PM   #1
Registered: Mar 2008
Posts: 52

Rep: Reputation: 15
Linux Shell Command - Issue

I am facing an issue in linux. when running a shell script file with parameter to java file i.e whenever i encounter single quotes , it is getting truncated . is a Shell script file

Shell Command:
sh -sql "insert into test values(1,'Robert','s')"

Content of shell script file:
java -jar AI/$AI/java/$AI.jar $1 \'"$2"\'

Result in java file : insert into test values(1,Robert ,s)
Expected Result in java file: insert into test values(1,'Robert ','s')

Please help me resolve this Urgent issue in Shell command !
Old 03-14-2008, 09:34 PM   #2
Senior Member
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
hmm... I'll venture a guess:

the double quotes are working on the command line, but get stripped when being sent to the shell script, so when the shell gets the argument, it's a single argument, but sans the double quotes & only has single quotes... which it then treats as containers & ships them off to the java app, stripped of the single quotes.

maybe something like:

sh -sql "\"insert into test values(1,'Robert','s')\""

that's a total guess, but I'd imagine that the solution will have some sort of escaped quotes - single and/or double.
Old 03-15-2008, 03:13 PM   #3
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
not a networking question. moved to Linux - Newbie
Old 03-15-2008, 08:53 PM   #4
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914
Sick of bot posting problems from a different forum verbatim on LQ
in irrelevant boards. Banning the thing and closing the threads.

Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unix vs. Linux shell command Chong Programming 10 01-12-2007 08:41 AM
Call Linux Shell Command from within *.c program in userspace? pat_and_cami SUSE / openSUSE 1 03-08-2006 02:39 AM
shell command to shutdown linux OS alix123 Programming 3 08-22-2005 08:17 AM
Linux shell command questions BabaKali Linux - Newbie 4 11-09-2004 08:03 PM
How to call the arp linux shell command from within a perl program Bassam Programming 1 03-11-2004 02:00 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:58 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration