LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 06-08-2012, 07:38 PM   #1
fachhoch@gmail.com
Member
 
Registered: Apr 2010
Posts: 82

Rep: Reputation: 1
calling curl inside .sh file


I have setenv.sh file used by tomcat, I can set java otpions in this sh file.
I want to use curl to get a value capture it in a variable and use it as a java opts its not working , please help me .Here is my script
Code:
#!/bin/sh
export JAVA_HOME=/opt/java
export JAVA_OPTS="-Xms1024m -Xmx1024m -XX:MaxPermSize=256m"
JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote.ssl=false"
JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote.authenticate=false"
PUBLIC_DNS=curl http://169.254.169.254/latest/meta-data/public-hostname

#export PUBLIC_DNS="${PUBLIC_DNS}"
JAVA_OPTS="${JAVA_OPTS} -Djava.rmi.server.hostname=${PUBLIC_DNS}"
echo "JAVA_OPTS=${JAVA_OPTS}"
CATALINA_PID=/var/run/tomcat.pid
I am assuming PUBLIC_DNS=curl http://169.254.169.254/latest/meta-data/public-hostname will get the value into PUBLIC_DNS , but this is always blank.
Please advice me whats wrong.
 
Old 06-09-2012, 02:54 AM   #2
notihnio
LQ Newbie
 
Registered: Oct 2009
Location: Greece
Distribution: slackware-current
Posts: 23

Rep: Reputation: 5
try to replace
Code:
PUBLIC_DNS=curl http://169.254.169.254/latest/meta-data/public-hostname
with
Code:
PUBLIC_DNS='curl http://169.254.169.254/latest/meta-data/public-hostname'
 
Old 06-09-2012, 03:02 AM   #3
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 609

Rep: Reputation: 180Reputation: 180
Quote:
Originally Posted by notihnio View Post
try to replace
Code:
PUBLIC_DNS=curl http://169.254.169.254/latest/meta-data/public-hostname
with
Code:
PUBLIC_DNS='curl http://169.254.169.254/latest/meta-data/public-hostname'
Nope. You have to use backticks instead of single quotes or the $(cmd) form.
The correct forms are
Code:
PUBLIC_DNS=`curl http://169.254.169.254/latest/meta-data/public-hostname`
PUBLIC_DNS=$(curl http://169.254.169.254/latest/meta-data/public-hostname)

Last edited by 414N; 06-09-2012 at 03:05 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
[SOLVED] Help calling a shell script inside a python script WyoChuck Linux - Newbie 4 05-28-2012 10:39 PM
Calling Remote Flash Game URL Using CURL stranger_6_7 Linux - General 0 05-13-2008 08:15 AM
not calling function inside switch case??? sarathius Programming 2 01-29-2008 11:38 AM
calling a c++ binary inside a perl script Blue_muppet Programming 3 08-29-2004 12:31 AM
calling sys_read inside sys_write returns number of bytes read as zero appas Linux - Software 0 08-28-2004 08:21 AM


All times are GMT -5. The time now is 11:28 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