Cannot send a populated variable as command line arguments [on hold]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












Hi I am new to shell scripting , struggling with a simple problem



I am dynamically populating a variable in a shell script and later accessing it send it as a command line arguments to call my java test framework



I am able to see the 2 of 3 arguments that have been populated but not one , dont understand why



admin_api_pw=$(cat $APP_NAME_credstash_settings.yml | grep "admin_api" -A3 | grep "password" | cut -d '"' -f2)
ip_addresss=$(curl http://XXX.XXX.XXX.254/latest/meta-data/local-ipv4)

echo $!admin_api_pw
echo $!admin_api_pw >> /tmp/admin_pw
echo $!ip_addresss >> /tmp/ip_addr

sh validate_app.sh appName


validate.sh has



java -cp "pingTestFramework.jar" com.ping.test.TestRunner $1 $(cat /tmp/admin_pw) $(cat /tmp/ip_addr)


I can see ip_addr and appName arguments, but cannot access the admin_api_pw arg , always throws an error



Exception is the java ArrayIndexOutOfBoundException , because its missing one command line argument



Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
at com.ping.test.TestRunner.main(TestRunner.java:9)










share|improve this question









New contributor




Vinod Siragaon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as unclear what you're asking by Michael Homer, RalfFriedl, Jeff Schaller, Archemar, G-Man Nov 20 at 6:18


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 1




    Please clarify what you mean by "cannot access the admin_api_pw arg"... What happens when you try to access it? You also say "always throws an error"... What error does it throw? You might have an issue with quoting here, especially if your password has meta-characters in it, or perhaps if it includes spaces...
    – Filipe Brandenburger
    Nov 19 at 6:22










  • You can see the debugging output of your script by running it with bash -x. You can then check each assignment to quickly narrow down the problem.
    – Haxiel
    Nov 19 at 6:27






  • 1




    It seems unlikely that http://XXX.XXX.XXX.254/latest/meta-data/local-ipv4 returns a valid variable name as $!ip_addresss would require; is this your actual code? Appending to the files also feels deeply dubious. Which two arguments do you think you see?
    – Michael Homer
    Nov 19 at 8:41










  • Extending Michael's comment: Please explain why you use ! in $!admin_api_pw
    – glenn jackman
    Nov 19 at 19:10














up vote
0
down vote

favorite












Hi I am new to shell scripting , struggling with a simple problem



I am dynamically populating a variable in a shell script and later accessing it send it as a command line arguments to call my java test framework



I am able to see the 2 of 3 arguments that have been populated but not one , dont understand why



admin_api_pw=$(cat $APP_NAME_credstash_settings.yml | grep "admin_api" -A3 | grep "password" | cut -d '"' -f2)
ip_addresss=$(curl http://XXX.XXX.XXX.254/latest/meta-data/local-ipv4)

echo $!admin_api_pw
echo $!admin_api_pw >> /tmp/admin_pw
echo $!ip_addresss >> /tmp/ip_addr

sh validate_app.sh appName


validate.sh has



java -cp "pingTestFramework.jar" com.ping.test.TestRunner $1 $(cat /tmp/admin_pw) $(cat /tmp/ip_addr)


I can see ip_addr and appName arguments, but cannot access the admin_api_pw arg , always throws an error



Exception is the java ArrayIndexOutOfBoundException , because its missing one command line argument



Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
at com.ping.test.TestRunner.main(TestRunner.java:9)










share|improve this question









New contributor




Vinod Siragaon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as unclear what you're asking by Michael Homer, RalfFriedl, Jeff Schaller, Archemar, G-Man Nov 20 at 6:18


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 1




    Please clarify what you mean by "cannot access the admin_api_pw arg"... What happens when you try to access it? You also say "always throws an error"... What error does it throw? You might have an issue with quoting here, especially if your password has meta-characters in it, or perhaps if it includes spaces...
    – Filipe Brandenburger
    Nov 19 at 6:22










  • You can see the debugging output of your script by running it with bash -x. You can then check each assignment to quickly narrow down the problem.
    – Haxiel
    Nov 19 at 6:27






  • 1




    It seems unlikely that http://XXX.XXX.XXX.254/latest/meta-data/local-ipv4 returns a valid variable name as $!ip_addresss would require; is this your actual code? Appending to the files also feels deeply dubious. Which two arguments do you think you see?
    – Michael Homer
    Nov 19 at 8:41










  • Extending Michael's comment: Please explain why you use ! in $!admin_api_pw
    – glenn jackman
    Nov 19 at 19:10












up vote
0
down vote

favorite









up vote
0
down vote

favorite











Hi I am new to shell scripting , struggling with a simple problem



I am dynamically populating a variable in a shell script and later accessing it send it as a command line arguments to call my java test framework



I am able to see the 2 of 3 arguments that have been populated but not one , dont understand why



admin_api_pw=$(cat $APP_NAME_credstash_settings.yml | grep "admin_api" -A3 | grep "password" | cut -d '"' -f2)
ip_addresss=$(curl http://XXX.XXX.XXX.254/latest/meta-data/local-ipv4)

echo $!admin_api_pw
echo $!admin_api_pw >> /tmp/admin_pw
echo $!ip_addresss >> /tmp/ip_addr

sh validate_app.sh appName


validate.sh has



java -cp "pingTestFramework.jar" com.ping.test.TestRunner $1 $(cat /tmp/admin_pw) $(cat /tmp/ip_addr)


I can see ip_addr and appName arguments, but cannot access the admin_api_pw arg , always throws an error



Exception is the java ArrayIndexOutOfBoundException , because its missing one command line argument



Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
at com.ping.test.TestRunner.main(TestRunner.java:9)










share|improve this question









New contributor




Vinod Siragaon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











Hi I am new to shell scripting , struggling with a simple problem



I am dynamically populating a variable in a shell script and later accessing it send it as a command line arguments to call my java test framework



I am able to see the 2 of 3 arguments that have been populated but not one , dont understand why



admin_api_pw=$(cat $APP_NAME_credstash_settings.yml | grep "admin_api" -A3 | grep "password" | cut -d '"' -f2)
ip_addresss=$(curl http://XXX.XXX.XXX.254/latest/meta-data/local-ipv4)

echo $!admin_api_pw
echo $!admin_api_pw >> /tmp/admin_pw
echo $!ip_addresss >> /tmp/ip_addr

sh validate_app.sh appName


validate.sh has



java -cp "pingTestFramework.jar" com.ping.test.TestRunner $1 $(cat /tmp/admin_pw) $(cat /tmp/ip_addr)


I can see ip_addr and appName arguments, but cannot access the admin_api_pw arg , always throws an error



Exception is the java ArrayIndexOutOfBoundException , because its missing one command line argument



Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
at com.ping.test.TestRunner.main(TestRunner.java:9)







shell command-line java arguments






share|improve this question









New contributor




Vinod Siragaon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Vinod Siragaon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Nov 19 at 6:28





















New contributor




Vinod Siragaon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Nov 19 at 6:15









Vinod Siragaon

11




11




New contributor




Vinod Siragaon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Vinod Siragaon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Vinod Siragaon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




put on hold as unclear what you're asking by Michael Homer, RalfFriedl, Jeff Schaller, Archemar, G-Man Nov 20 at 6:18


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






put on hold as unclear what you're asking by Michael Homer, RalfFriedl, Jeff Schaller, Archemar, G-Man Nov 20 at 6:18


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









  • 1




    Please clarify what you mean by "cannot access the admin_api_pw arg"... What happens when you try to access it? You also say "always throws an error"... What error does it throw? You might have an issue with quoting here, especially if your password has meta-characters in it, or perhaps if it includes spaces...
    – Filipe Brandenburger
    Nov 19 at 6:22










  • You can see the debugging output of your script by running it with bash -x. You can then check each assignment to quickly narrow down the problem.
    – Haxiel
    Nov 19 at 6:27






  • 1




    It seems unlikely that http://XXX.XXX.XXX.254/latest/meta-data/local-ipv4 returns a valid variable name as $!ip_addresss would require; is this your actual code? Appending to the files also feels deeply dubious. Which two arguments do you think you see?
    – Michael Homer
    Nov 19 at 8:41










  • Extending Michael's comment: Please explain why you use ! in $!admin_api_pw
    – glenn jackman
    Nov 19 at 19:10












  • 1




    Please clarify what you mean by "cannot access the admin_api_pw arg"... What happens when you try to access it? You also say "always throws an error"... What error does it throw? You might have an issue with quoting here, especially if your password has meta-characters in it, or perhaps if it includes spaces...
    – Filipe Brandenburger
    Nov 19 at 6:22










  • You can see the debugging output of your script by running it with bash -x. You can then check each assignment to quickly narrow down the problem.
    – Haxiel
    Nov 19 at 6:27






  • 1




    It seems unlikely that http://XXX.XXX.XXX.254/latest/meta-data/local-ipv4 returns a valid variable name as $!ip_addresss would require; is this your actual code? Appending to the files also feels deeply dubious. Which two arguments do you think you see?
    – Michael Homer
    Nov 19 at 8:41










  • Extending Michael's comment: Please explain why you use ! in $!admin_api_pw
    – glenn jackman
    Nov 19 at 19:10







1




1




Please clarify what you mean by "cannot access the admin_api_pw arg"... What happens when you try to access it? You also say "always throws an error"... What error does it throw? You might have an issue with quoting here, especially if your password has meta-characters in it, or perhaps if it includes spaces...
– Filipe Brandenburger
Nov 19 at 6:22




Please clarify what you mean by "cannot access the admin_api_pw arg"... What happens when you try to access it? You also say "always throws an error"... What error does it throw? You might have an issue with quoting here, especially if your password has meta-characters in it, or perhaps if it includes spaces...
– Filipe Brandenburger
Nov 19 at 6:22












You can see the debugging output of your script by running it with bash -x. You can then check each assignment to quickly narrow down the problem.
– Haxiel
Nov 19 at 6:27




You can see the debugging output of your script by running it with bash -x. You can then check each assignment to quickly narrow down the problem.
– Haxiel
Nov 19 at 6:27




1




1




It seems unlikely that http://XXX.XXX.XXX.254/latest/meta-data/local-ipv4 returns a valid variable name as $!ip_addresss would require; is this your actual code? Appending to the files also feels deeply dubious. Which two arguments do you think you see?
– Michael Homer
Nov 19 at 8:41




It seems unlikely that http://XXX.XXX.XXX.254/latest/meta-data/local-ipv4 returns a valid variable name as $!ip_addresss would require; is this your actual code? Appending to the files also feels deeply dubious. Which two arguments do you think you see?
– Michael Homer
Nov 19 at 8:41












Extending Michael's comment: Please explain why you use ! in $!admin_api_pw
– glenn jackman
Nov 19 at 19:10




Extending Michael's comment: Please explain why you use ! in $!admin_api_pw
– glenn jackman
Nov 19 at 19:10















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay