LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Pass space (or string escaped) as argument to shell script. (https://www.linuxquestions.org/questions/programming-9/pass-space-or-string-escaped-as-argument-to-shell-script-760317/)

scmbg 10-07-2009 09:41 AM

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.

scmbg 10-07-2009 10:15 AM

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"


All times are GMT -5. The time now is 09:57 AM.