Show local ip inside .sh script [closed]
Clash Royale CLAN TAG#URR8PPP
up vote
-3
down vote
favorite
We want to show local server ip inside .sh script, any ideas how this could be done ?
linux bash shell
closed as too broad by roaima, steve, Jeff Schaller, G-Man, maxschlepzig Nov 24 at 12:48
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. 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.
add a comment |
up vote
-3
down vote
favorite
We want to show local server ip inside .sh script, any ideas how this could be done ?
linux bash shell
closed as too broad by roaima, steve, Jeff Schaller, G-Man, maxschlepzig Nov 24 at 12:48
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. 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.
2
That's not an example. If you want an answer without even bothering to try then why not buy some consultancy.
– roaima
Nov 23 at 21:42
add a comment |
up vote
-3
down vote
favorite
up vote
-3
down vote
favorite
We want to show local server ip inside .sh script, any ideas how this could be done ?
linux bash shell
We want to show local server ip inside .sh script, any ideas how this could be done ?
linux bash shell
linux bash shell
edited Nov 23 at 21:42
roaima
42.2k550115
42.2k550115
asked Nov 23 at 20:49
Ali EL KANDOUSSI
54
54
closed as too broad by roaima, steve, Jeff Schaller, G-Man, maxschlepzig Nov 24 at 12:48
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. 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.
closed as too broad by roaima, steve, Jeff Schaller, G-Man, maxschlepzig Nov 24 at 12:48
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. 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.
2
That's not an example. If you want an answer without even bothering to try then why not buy some consultancy.
– roaima
Nov 23 at 21:42
add a comment |
2
That's not an example. If you want an answer without even bothering to try then why not buy some consultancy.
– roaima
Nov 23 at 21:42
2
2
That's not an example. If you want an answer without even bothering to try then why not buy some consultancy.
– roaima
Nov 23 at 21:42
That's not an example. If you want an answer without even bothering to try then why not buy some consultancy.
– roaima
Nov 23 at 21:42
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
You can use something like this:
localiphere=$(hostname -i)
But the exact command to be used inside the parenthesis depends on how many IPs you have on a server and which distribution you are using.
Basically, you need to put the command which will return the server IP, but that command will vary from system to system. On Debian hostname -i
will return the main server IP.
If you are looking for server public IP and not private IPs, even if you have multiple public IPs on your server, you can use online services like ifconfig.co and similar to get main public IP of the server regardless of the system you are running.
localiphere=$(curl ifconfig.co)
With RHEL7:hostname -I
– Cyrus
Nov 23 at 21:57
In my Debianhostname -i
returns127.0.0.1
whilehostname -I
returns192.168.1.120
– George Vasiliou
Nov 25 at 21:47
-I should return all IP addresses, from manpage, [-I|--all-ip-addresses], it returns all IPs on all Debians I tried it.
– rAlen
Nov 26 at 5:42
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
You can use something like this:
localiphere=$(hostname -i)
But the exact command to be used inside the parenthesis depends on how many IPs you have on a server and which distribution you are using.
Basically, you need to put the command which will return the server IP, but that command will vary from system to system. On Debian hostname -i
will return the main server IP.
If you are looking for server public IP and not private IPs, even if you have multiple public IPs on your server, you can use online services like ifconfig.co and similar to get main public IP of the server regardless of the system you are running.
localiphere=$(curl ifconfig.co)
With RHEL7:hostname -I
– Cyrus
Nov 23 at 21:57
In my Debianhostname -i
returns127.0.0.1
whilehostname -I
returns192.168.1.120
– George Vasiliou
Nov 25 at 21:47
-I should return all IP addresses, from manpage, [-I|--all-ip-addresses], it returns all IPs on all Debians I tried it.
– rAlen
Nov 26 at 5:42
add a comment |
up vote
1
down vote
You can use something like this:
localiphere=$(hostname -i)
But the exact command to be used inside the parenthesis depends on how many IPs you have on a server and which distribution you are using.
Basically, you need to put the command which will return the server IP, but that command will vary from system to system. On Debian hostname -i
will return the main server IP.
If you are looking for server public IP and not private IPs, even if you have multiple public IPs on your server, you can use online services like ifconfig.co and similar to get main public IP of the server regardless of the system you are running.
localiphere=$(curl ifconfig.co)
With RHEL7:hostname -I
– Cyrus
Nov 23 at 21:57
In my Debianhostname -i
returns127.0.0.1
whilehostname -I
returns192.168.1.120
– George Vasiliou
Nov 25 at 21:47
-I should return all IP addresses, from manpage, [-I|--all-ip-addresses], it returns all IPs on all Debians I tried it.
– rAlen
Nov 26 at 5:42
add a comment |
up vote
1
down vote
up vote
1
down vote
You can use something like this:
localiphere=$(hostname -i)
But the exact command to be used inside the parenthesis depends on how many IPs you have on a server and which distribution you are using.
Basically, you need to put the command which will return the server IP, but that command will vary from system to system. On Debian hostname -i
will return the main server IP.
If you are looking for server public IP and not private IPs, even if you have multiple public IPs on your server, you can use online services like ifconfig.co and similar to get main public IP of the server regardless of the system you are running.
localiphere=$(curl ifconfig.co)
You can use something like this:
localiphere=$(hostname -i)
But the exact command to be used inside the parenthesis depends on how many IPs you have on a server and which distribution you are using.
Basically, you need to put the command which will return the server IP, but that command will vary from system to system. On Debian hostname -i
will return the main server IP.
If you are looking for server public IP and not private IPs, even if you have multiple public IPs on your server, you can use online services like ifconfig.co and similar to get main public IP of the server regardless of the system you are running.
localiphere=$(curl ifconfig.co)
edited Nov 26 at 5:47
answered Nov 23 at 21:23
rAlen
675410
675410
With RHEL7:hostname -I
– Cyrus
Nov 23 at 21:57
In my Debianhostname -i
returns127.0.0.1
whilehostname -I
returns192.168.1.120
– George Vasiliou
Nov 25 at 21:47
-I should return all IP addresses, from manpage, [-I|--all-ip-addresses], it returns all IPs on all Debians I tried it.
– rAlen
Nov 26 at 5:42
add a comment |
With RHEL7:hostname -I
– Cyrus
Nov 23 at 21:57
In my Debianhostname -i
returns127.0.0.1
whilehostname -I
returns192.168.1.120
– George Vasiliou
Nov 25 at 21:47
-I should return all IP addresses, from manpage, [-I|--all-ip-addresses], it returns all IPs on all Debians I tried it.
– rAlen
Nov 26 at 5:42
With RHEL7:
hostname -I
– Cyrus
Nov 23 at 21:57
With RHEL7:
hostname -I
– Cyrus
Nov 23 at 21:57
In my Debian
hostname -i
returns 127.0.0.1
while hostname -I
returns 192.168.1.120
– George Vasiliou
Nov 25 at 21:47
In my Debian
hostname -i
returns 127.0.0.1
while hostname -I
returns 192.168.1.120
– George Vasiliou
Nov 25 at 21:47
-I should return all IP addresses, from manpage, [-I|--all-ip-addresses], it returns all IPs on all Debians I tried it.
– rAlen
Nov 26 at 5:42
-I should return all IP addresses, from manpage, [-I|--all-ip-addresses], it returns all IPs on all Debians I tried it.
– rAlen
Nov 26 at 5:42
add a comment |
2
That's not an example. If you want an answer without even bothering to try then why not buy some consultancy.
– roaima
Nov 23 at 21:42