Sponsored Content
Top Forums Shell Programming and Scripting Eval command with space, quote and bracket characters Post 302949366 by Pradnya Gandhe on Friday 10th of July 2015 12:38:45 AM
Old 07-10-2015
Data Eval command with space, quote and bracket characters

Hi,
I am Pradnya Gandhe trying to use in shell script.
I want to use a bit complicated command using eval command in a shell script.
Code:
<path to>\wsadmin.sh -lang jython -conntype NONE -c "AdminApp.install('war file path', '[ -appname IDSWebApp -contextroot /IDSWebApp -MapModulesToServers [[ \"string" IDSWebApp.war,WEB-INF/web.xml WebSphere:server=server1 ]] -MapWebModToVH [[ \"string\" IDSWebApp.war,WEB-INF/web.xml default_host ]] -MapRolesToUsers [[ allusers AppDeploymentOption.No AppDeploymentOption.Yes \"\" \"\" AppDeploymentOption.No \"\" \"\" ]] ]')"

Works correctly as expected on shell prompt
Code:
<path to>\wsadmin.sh -lang jython -conntype NONE
wsadmin>above command

works correctly

I want to use this command in shell script, so I used eval command
eval "command" like following
Code:
eval <path to>\wsadmin.sh -lang jython -conntype NONE -c "AdminApp.install('war file path', '[ -appname IDSWebApp -contextroot /IDSWebApp -MapModulesToServers [[ \"string" IDSWebApp.war,WEB-INF/web.xml WebSphere:server=server1 ]] -MapWebModToVH [[ \"string\" IDSWebApp.war,WEB-INF/web.xml default_host ]] -MapRolesToUsers [[ allusers AppDeploymentOption.No AppDeploymentOption.Yes \"\" \"\" AppDeploymentOption.No \"\" \"\" ]] ]')"

It gives following error->
Code:
pg.sh: command substitution: line 10: syntax error near unexpected token `('
pg.sh: command substitution: line 10: `<path to>\wsadmin.sh -lang jython -conntype NONE -c '"'AdminApp.install('war file path', '[ -appname IDSWebApp -contextroot /IDSWebApp -MapModulesToServers [[ "string" IDSWebApp.war,WEB-INF/web.xml WebSphere:server=server1 ]] -MapWebModToVH [[ "string" IDSWebApp.war,WEB-INF/web.xml default_host ]] -MapRolesToUsers [[ allusers AppDeploymentOption.No AppDeploymentOption.Yes "" "" AppDeploymentOption.No "" "" ]] ]')'"''

I want to know rules to used in eval if command within it contains characters like brackets, quotes, space, etc.

This is all issue of characters which when passed over eval generates error.

Pls guide me.

Thanks and regards,
Pradnya Gandhe

Last edited by Don Cragun; 07-10-2015 at 03:06 AM.. Reason: Add CODE and ICODE tags.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Multiple characters including single quote in delimiter

Hello, I need to replace the comma to something else between the single quote: 1aaa,bbb,'cc,cc','ddd',1 2aaa,bbb,'ccc','d,d',0 to 1aaa,bbb,'cc<comma>cc','ddd',1 2aaa,bbb,'ccc','d<comma>d',0 Can someone help? Thanks. (2 Replies)
Discussion started by: bgirl
2 Replies

2. Shell Programming and Scripting

Regex in grep to match all lines ending with a double quote (") OR a single quote (')

Hi, I've been trying to write a regex to use in egrep (in a shell script) that'll fetch the names of all the files that match a particular pattern. I expect to match the following line in a file: Name = "abc" The regex I'm using to match the same is: egrep -l '(^) *= *" ** *"$' /PATH_TO_SEARCH... (6 Replies)
Discussion started by: NanJ
6 Replies

3. Shell Programming and Scripting

Processing data that contains space and quote delimiters

I need to write a Bash script to process a data file that is in this format: 1 A B C D E 2 F G "H H" I J As you can see, the data is delimited by a space, but there are also some fields that contain spaces and are surrounded by double-quotes. An example of that is "H H". I wrote... (7 Replies)
Discussion started by: RickS
7 Replies

4. Shell Programming and Scripting

Eval command help

I have file called myfile which has the text "myserver" in it. I need to have a command to ping "myserver". How would I do that? I tried when I type at the terminal I get the output as . How do I do something like a ? thanks, Nick (5 Replies)
Discussion started by: nikhilfake
5 Replies

5. Shell Programming and Scripting

Strange result of eval, how does eval really work with ssh?

Hi all, some small script with eval turned me to crazy. my OS is linux Linux s10-1310 2.6.16.53-0.8.PTF.434477.3.TDC.0-smp #1 SMP Fri Aug 31 06:07:27 PDT 2007 x86_64 x86_64 x86_64 GNU/Linux below script works well #!/bin/bash eval ssh remotehost date eval ssh remotehost ls below... (1 Reply)
Discussion started by: summer_cherry
1 Replies

6. Shell Programming and Scripting

ksh, difference between double bracket and single bracket

Can somebody tell me the difference between double brackets and single brackets, when doing a test. I have always been acustomed to using single brackets and have not encountered any issues to date. Why would somebody use double brackets. Ie if ] vs if Thanks to... (2 Replies)
Discussion started by: BeefStu
2 Replies

7. Shell Programming and Scripting

Error in eval eval command to print html tags

anyone has any info on why this is complaining??? vivek@vivek-c5e55ef2e ~/TAC $ zoneCounter=1 vivek@vivek-c5e55ef2e ~/TAC $ optUsage1=23% vivek@vivek-c5e55ef2e ~/TAC $ eval eval echo "<th>Zone $zoneCounter </th><th align=\"left\"> \$optUsage$zoneCounter </th>" -bash: syntax error... (1 Reply)
Discussion started by: vivek d r
1 Replies

8. Shell Programming and Scripting

Error in eval eval command to print html tags

anyone has any info on why this is complaining??? vivek@vivek-c5e55ef2e ~/TAC $ zoneCounter=1 vivek@vivek-c5e55ef2e ~/TAC $ optUsage1=23% vivek@vivek-c5e55ef2e ~/TAC $ eval eval echo "<th>Zone $zoneCounter </th><th align=\"left\"> \$optUsage$zoneCounter </th>" -bash: syntax error... (13 Replies)
Discussion started by: vivek d r
13 Replies

9. Shell Programming and Scripting

Replacing trailing space with single quote

Platform : RHEL 5.8 I want to end each line of this file with a single quote. $ cat hello.txt blueskies minnie mickey gravity snoopyAt VI editor's command mode, I have used the following command to replace the last character with a single quote. ~ ~ ~ :%s/$/'/gNow, the lines in the... (10 Replies)
Discussion started by: John K
10 Replies

10. Shell Programming and Scripting

Replacing all but the first and last double quote in a line with a single quote with awk

From: 1,2,3,4,5,This is a test 6,7,8,9,0,"This, is a test" 1,9,2,8,3,"This is a ""test""" 4,7,3,1,8,"""" To: 1,2,3,4,5,This is a test 6,7,8,9,0,"This; is a test" 1,9,2,8,3,"This is a ''test''" 4,7,3,1,8,"''"Is there an easy syntax I'm overlooking? There will always be an odd number... (5 Replies)
Discussion started by: Michael Stora
5 Replies
All times are GMT -4. The time now is 06:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy