Dig command repated SERVER value [closed] - bash

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I'm exploring the various options of dig command. I have disabled all output except the stats section:
$ options="+noanswer +nocmd +nocomments +stats"
$ dig example.com $options
;example.com. IN A
;; Query time: 41 msec
;; SERVER: 75.75.75.75#53(75.75.75.75)
;; WHEN: Wed Apr 01 11:59:25 MDT 2020
;; MSG SIZE rcvd: 56
$ dig stackoverflow.com $options
;stackoverflow.com. IN A
;; Query time: 49 msec
;; SERVER: 75.75.75.75#53(75.75.75.75)
;; WHEN: Wed Apr 01 11:59:43 MDT 2020
;; MSG SIZE rcvd: 110
Why these two different domains return the same SERVER? Every domain that I have tried return the same SERVER value.

;; SERVER: 75.75.75.75#53(75.75.75.75)
Is the DNS Name-server used during the dig command.
You can confirm this by checking which name-server your computer uses;
$ dig +noanswer +nocmd +nocomments +stats example.com
...
;; SERVER: 172.18.0.254#53(172.18.0.254)
...
$ cat /etc/resolv.conf | tail -n 1
nameserver 172.18.0.254
I'm using a local custom DNS server, therefore the local ip ;)

Related

Obtain the hostname served by a Kubernetes Ingress [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 11 months ago.
This post was edited and submitted for review 6 months ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
How to resolve the domain/hostname of a K8s Service, that a specific K8s Ingress is serving?
In the namespace foobar, I want to know where to connect for the service provided by the ingress.
kubectl --namespace foobar get ingress
returns the available ones, and
kubectl --namespace foobar describe ingress/bazbar
returns the details; I can match by name (e.g. barbaz) the one I'm targeting.
But how can I extrapolate the host (and, possibly, also the path) to then launch it in the browser with xdg-open?
The below should solve your query on getting domain per namespace.
The query below "get ingress" retrieves the domain details from all namespaces and using awk, it prints the 1st column which is the namespace and the 4th column which is the domain in the ingress, you can grep it further to filter down on particular namespace.
#To get all namespace and domain
kubectl get ingress --all-namespaces|awk '{print $1 " | " $4 }'
foobar | foobar.example.com
barfoo | barfoo.example.com
#To filter on namespace from all namespace
kubectl get ingress --all-namespaces|awk '{print $1 " | " $4 }'|grep -i foobar
foobar | foobar.example.com
#To get one namespace
kubectl get ingress -n <namespace-name>|awk '{print $1 " | " $4 }'
foobar | foobar.example.com

Get currency exchange rate using bash [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed last year.
Improve this question
I would like to display the current exchange rate from the currency euro to us dollar in the command line using bash shell script. I'm using the website market insider.
I saw on someone's blog to use wget command
wget -qO- https://markets.businessinsider.com/currencies/eur-usd
But how can I display only the rate? Desired output (example for current rate 1.1347) --> 1.1347 $
PS: I would prefer not to use API
Any help would be appreciated
Do this cleanly using their API:
#!/usr/bin/env bash
API='https://markets.businessinsider.com/ajax/'
ExchangeRate_GetConversionForCurrenciesNumbers() {
isoCodeForeign=$1
isoCodeLocal=$2
amount=$3
date=$4
cacheFile="/tmp/$date-$amount-$isoCodeForeign-$isoCodeLocal.json"
# Check if we have cached the result to avoid front-running the API
if ! [ -e "$cacheFile" ]; then
post_vars=(
isoCodeForeign="$isoCodeForeign"
isoCodeLocal="$isoCodeLocal"
amount="$amount"
date="$date"
)
method='ExchangeRate_GetConversionForCurrenciesNumbers'
IFS='&' url="$API$method?${post_vars[*]}"
curl -s -X POST "$url" > "$cacheFile"
fi
jq -r '.ConvertedAmountFourDigits' "$cacheFile"
}
getRateEURO_USToday() {
ExchangeRate_GetConversionForCurrenciesNumbers EUR USD 1 "$(date '+%Y-%m-%d')"
}
# Set LC_NUMERIC=C because the float format returned is using . as decimal
LC_NUMERIC=C printf 'The exchange rate for EUR to USD today is: %.4f\n' \
"$(getRateEURO_USToday)"

what does this command line do? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I am working through this resource: https://cmdchallenge.com
On the following challenge: https://cmdchallenge.com/s/#/search_for_files_containing_string, the problem was:
Print all files in the current directory,
one per line (not the path, just the filename)
that contain the string "500".
When I ran:
ls -al
I got the following:
total 36
drwxr-xr-x. 2 501 dialout 4096 Feb 10 21:08 .
drwxr-xr-x. 39 501 dialout 4096 Apr 18 19:04 ..
-rw-r--r--. 1 501 dialout 204 Apr 29 17:44 README
lrwxrwxrwx. 1 501 dialout 23 Feb 10 20:59 access.log -> ../../common/access.log
lrwxrwxrwx. 1 501 dialout 25 Feb 10 21:08 access.log.1 -> ../../common/access.log.1
lrwxrwxrwx. 1 501 dialout 25 Feb 10 21:08 access.log.2 -> ../../common/access.log.2
I tried a few things, then looked at the user submitted solutions and one of them was:
ls *[^2]
I did some googling and the man page (and here), but I can't see what this is doing, or how it works.
Can anyone point me to a decent resource so I can read up on it, or tell me how it works?
Let me first quote PesaThes comment to what the command does:
The reference you are looking for is in the manual under: pattern matching. * matches any string, [^2] matches any character that is not 2. So the command lists all files that do not end in 2
Now why this is a solution to the problem is not so clear from your question alone. But if you look what the files contain you will notice that indeed, access.log.2 is the only one that does not contain the string 500 and also the only one whose name ends in 2.
For other sets of files the command ls *[^2] will most probably not output all the files without the string 500 in it, but in this case with those specific files it matches the right files. Another solution would have been for example
echo README; echo access.log; echo access.log.1
that's not an answer to your question, the right way of doing it is
$ grep -sl 500 * .*
-s skip errors (caused by directories); l only filenames; search in * all visible files and .* invisible files.

Name of the users which executed a command [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I want to get the name of the users which executed a command (for example cat).
fc -l will provide a list with the most recent commands executed by the current user but is there an way to find out the history for all users?
I read the manual but i could not find something that would help
Do you know any other commands which would do this job?
I also tried w and who
I found this solution: the super user will search in each dir from "home" in the .bash_history and make a grep on that file for that command. It will work but is this optimal?
Using awk =)
awk -v monitoredcmd=cat '
$1~"^#[0-9]{10,}\s*$"{
sub(/#/,"")
tmpdate=$1
}
$1==monitoredcmd{
"date -d #"tmpdate | getline date
close("date -d #"tmpdate)
print "command [" $0 "] by",
gensub(/\/home\/([^\/]+).*/, "\\1", "", FILENAME),
at,
date
}
' /home/*/.bash_history
Sample Output
command [cat file.txt] by sputnick mer. févr. 13 15:34:44 CET 2013
command [cat l.py] by sputnick mer. févr. 13 15:45:38 CET 2013
command [cat foobar.pl] by marc mer. févr. 13 15:47:54 CET 2013

Mac OS X Lion cannot resolve localhost [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I have found serval questions about this but no one helps for me, I am searching for
days to get my problem solved but I can't get it done, I hope someone can help
me with this big issue.
I try to ping my localhost, I need this to develop my web apps. I do this by zendServer.
This problem cames up when I upgraded my OS X to Lion.
I use internet over Apple timecapsule but I think this doesn't matter to make it able to use your localhost?
Host file (sudo nano /private/etc/hosts):
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
Dig result:
leny-pc:~ nickyklaasse$ dig localhost
; <<>> DiG 9.7.3-P3 <<>> localhost
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18908
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;localhost. IN A
;; ANSWER SECTION:
localhost. 10800 IN A 127.0.0.1
;; Query time: 20 msec
;; SERVER: 192.168.1.254#53(192.168.1.254)
;; WHEN: Thu Dec 1 13:08:07 2011
;; MSG SIZE rcvd: 43
Host result:
leny-pc:~ nickyklaasse$ host localhost
localhost has address 127.0.0.1
localhost has IPv6 address ::1
Ping result:
leny-pc:~ nickyklaasse$ ping localhost
ping: cannot resolve localhost: Unknown host
I hope some one can help me to an answer.
With kind regards,
Nicky
Comment this 2 lines and try again:
::1 localhost
fe80::1%lo0 localhost
and let me know what happen
Resolved by a clean new installation of Mac Os Lion by DVD

Resources