Calling .sh(shell script) with the required parameters as below :-
sh home/example.sh --context_param dbUserName=username --context_param dbPassword=exam!ple##### --context_param resultDate=2017-01-13
calling example.sh with paramters dbUsername and password but getting following error:-
-bash: !ple#####: event not found
I think special characters restrict the command to execute. Then how i have to pass the special characters. Any help will be appreciable.
Change the line,
dbPassword=exam!ple#####
to,
dbPassword='exam!ple#####'
to avoid !
(history-expansion) being treated specially in bash
From man bash
under QUOTING
sub-section,
When the command history expansion facilities are being used (see HISTORY EXPANSION below), the history expansion character, usually !, must be quoted to prevent history expansion.
more under HISTORY EXPANSION
History expansions are introduced by the appearance of the history expansion character, which is ! by default. Only backslash (
\
) and single quotes can quote the history expansion character.
Also, it is a good practice to quote all your name-value
pairs to prevent Word-splitting done by shell.
sh home/example.sh --context_param dbUserName="username" --context_param dbPassword='exam!ple#####' --context_param resultDate="2017-01-13"
About word-splitting, from the man
page,
Word Splitting
The shell scans the results of parameter expansion, command substitution, and arithmetic expansion that did not occur within double quotes for word splitting. The shell treats each character of
IFS
as a delimiter, and splits the results of the other expansions into words using these characters as field terminators