LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 10-07-2009, 10:41 AM   #1
scmbg
Member
 
Registered: Oct 2008
Location: Mexico City
Distribution: Fedora
Posts: 65

Rep: Reputation: 15
Pass space (or string escaped) as argument to shell script.


Hello, i need to pass a message to my Java, I use a shell script tu set all the environment.

I use this code inside the script:
Code:
java -cp $CP App $1 $2
But when i try to run the script and pass a string like this:

Code:
./AppShell SndMsg "Wellcome to my app"
"Wellcome to my app" is send as 4 differente arguments.

This happend to if I use:

Code:
./AppShell SndMsg "Wellcome\ to\ my\ app"
Code:
./AppShell SndMsg Wellcome\ to\ my\ app
How can i pass the second parameter as complete string to my shell and then passed to my java app.
 
Old 10-07-2009, 11:15 AM   #2
scmbg
Member
 
Registered: Oct 2008
Location: Mexico City
Distribution: Fedora
Posts: 65

Original Poster
Rep: Reputation: 15
Solved, sorry the way is pass the shell variable between quotes, like this:

Code:
java -cp $CP App $1 "$2"
and launch the script this way:

Code:
./AppShell SndMsg "Wellcome to my app"

Last edited by scmbg; 10-07-2009 at 11:16 AM.
 
  


Reply


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
Possible to pass an argument from one shell env to another? ne00 Programming 4 04-15-2009 10:19 PM
Python: need to pass quoted string to an exec call; prob w/ escaped chars BrianK Programming 4 12-22-2008 08:49 PM
Howto pass an argument to alias of a script? Goose1 Programming 1 02-17-2008 07:14 PM
shell script, Passing string as argument? antis Programming 4 09-07-2007 02:03 AM
PHP pass argument to shell script monzter Programming 2 08-14-2004 07:16 AM


All times are GMT -5. The time now is 11:13 AM.

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