Re: [gentoo-user] ip_change_notifier - empty IP address
Thelma On 6/27/23 13:23, Neil Bothwick wrote: On Tue, 27 Jun 2023 11:48:16 -0600, the...@sys-concept.com wrote: On 6/27/23 11:04, Neil Bothwick wrote: On Tue, 27 Jun 2023 10:34:22 -0600, the...@sys-concept.com wrote: I run this little script to notify me when the IP changes. However at time to time the file: "old_ip.txt" is being populated with an empty line "no IP address" What could be causing it? #!/bin/bash # Replace "YOUR_EMAIL" with your actual email address EMAIL="your_em...@gmail.com" # File to store the old IP address IP_FILE="/home/fd/business/scripts/old_ip.txt" # Read the old IP address from the file OLD_IP=$(cat "$IP_FILE") # Function to retrieve the IP address get_ip_address() { local ip_address ip_address=$(curl -s https://ifconfig.me/ip) echo "$ip_address" } # Query the API to get the current IP address NEW_IP=$(curl -s https://api.ipify.org) I found this site very slow to respond. It could be timing out with an empty result. OTOH the URL used in the get_ip_address function is rapid, but you don't call that function. sleep 2 Yes, I notice it, it take upwards 10sec to get an IP and sometimes I get a timeout, I increases "sleep 15" hopefully it will help. It won't because the curl command is running synchronously. All increasing the sleep does is make you wait longer after it fails. Why not simply switch to the other service that seems to work more reliably? I think this is better version: #!/bin/bash # Replace "YOUR_EMAIL" with your actual email address EMAIL="your_em...@gmail.com" # File to store the old IP address IP_FILE="/home/fd/business/scripts/old_ip.txt" # Read the old IP address from the file OLD_IP=$(cat "$IP_FILE") # Function to retrieve the IP address get_ip_address() { local ip_address ip_address=$(wget -qO- ipinfo.io/ip) echo "$ip_address" } # Query the API to get the current IP address NEW_IP=$(get_ip_address) # Retry if the IP address is empty retry_count=0 while [[ -z "$NEW_IP" && $retry_count -lt 3 ]]; do sleep 1 NEW_IP=$(get_ip_address) ((retry_count++)) done # Compare the new IP address with the old one if [[ "$NEW_IP" != "$OLD_IP" ]]; then echo "Your IP address has changed to $NEW_IP" # Send an email notification echo "New IP address: $NEW_IP" | mailto -s "IP address change" $EMAIL # Update the old IP address in the file echo -n "$NEW_IP" >| "$IP_FILE" else echo "Your IP address is still $OLD_IP" fi
Re: [gentoo-user] ip_change_notifier - empty IP address
On 6/27/23 13:23, Neil Bothwick wrote: On Tue, 27 Jun 2023 11:48:16 -0600, the...@sys-concept.com wrote: On 6/27/23 11:04, Neil Bothwick wrote: On Tue, 27 Jun 2023 10:34:22 -0600, the...@sys-concept.com wrote: I run this little script to notify me when the IP changes. However at time to time the file: "old_ip.txt" is being populated with an empty line "no IP address" What could be causing it? #!/bin/bash # Replace "YOUR_EMAIL" with your actual email address EMAIL="your_em...@gmail.com" # File to store the old IP address IP_FILE="/home/fd/business/scripts/old_ip.txt" # Read the old IP address from the file OLD_IP=$(cat "$IP_FILE") # Function to retrieve the IP address get_ip_address() { local ip_address ip_address=$(curl -s https://ifconfig.me/ip) echo "$ip_address" } # Query the API to get the current IP address NEW_IP=$(curl -s https://api.ipify.org) I found this site very slow to respond. It could be timing out with an empty result. OTOH the URL used in the get_ip_address function is rapid, but you don't call that function. sleep 2 Yes, I notice it, it take upwards 10sec to get an IP and sometimes I get a timeout, I increases "sleep 15" hopefully it will help. It won't because the curl command is running synchronously. All increasing the sleep does is make you wait longer after it fails. Why not simply switch to the other service that seems to work more reliably? Hmm,... do you mean i run: NEW_IP=$(curl -s https://ifconfig.me/ip) I tried it. When the "curl -s https://ifconfig.me/ip; failed, showing empty IP curl -s https://ifconfig.me/ip was empty as well.
Re: [gentoo-user] ip_change_notifier - empty IP address
On Tue, 27 Jun 2023 11:48:16 -0600, the...@sys-concept.com wrote: > On 6/27/23 11:04, Neil Bothwick wrote: > > On Tue, 27 Jun 2023 10:34:22 -0600, the...@sys-concept.com wrote: > > > >> I run this little script to notify me when the IP changes. However > >> at time to time the file: "old_ip.txt" is being populated with an > >> empty line "no IP address" > >> > >> What could be causing it? > >> > >> > >> #!/bin/bash > >> > >> # Replace "YOUR_EMAIL" with your actual email address > >> EMAIL="your_em...@gmail.com" > >> > >> # File to store the old IP address > >> IP_FILE="/home/fd/business/scripts/old_ip.txt" > >> > >> # Read the old IP address from the file > >> OLD_IP=$(cat "$IP_FILE") > >> > >> # Function to retrieve the IP address > >> get_ip_address() { > >> local ip_address > >> ip_address=$(curl -s https://ifconfig.me/ip) > >> echo "$ip_address" > >> } > >> > >> # Query the API to get the current IP address > >> NEW_IP=$(curl -s https://api.ipify.org) > > > > I found this site very slow to respond. It could be timing out with an > > empty result. OTOH the URL used in the get_ip_address function is > > rapid, but you don't call that function. > > > >> > >> sleep 2 > > Yes, I notice it, it take upwards 10sec to get an IP and sometimes I > get a timeout, I increases "sleep 15" hopefully it will help. It won't because the curl command is running synchronously. All increasing the sleep does is make you wait longer after it fails. Why not simply switch to the other service that seems to work more reliably? -- Neil Bothwick If someone with multiple personalities threatens to kill himself, is it considered a hostage situation? pgpLsmerRR4LQ.pgp Description: OpenPGP digital signature
Re: [gentoo-user] ip_change_notifier - empty IP address
On 6/27/23 11:04, Neil Bothwick wrote: On Tue, 27 Jun 2023 10:34:22 -0600, the...@sys-concept.com wrote: I run this little script to notify me when the IP changes. However at time to time the file: "old_ip.txt" is being populated with an empty line "no IP address" What could be causing it? #!/bin/bash # Replace "YOUR_EMAIL" with your actual email address EMAIL="your_em...@gmail.com" # File to store the old IP address IP_FILE="/home/fd/business/scripts/old_ip.txt" # Read the old IP address from the file OLD_IP=$(cat "$IP_FILE") # Function to retrieve the IP address get_ip_address() { local ip_address ip_address=$(curl -s https://ifconfig.me/ip) echo "$ip_address" } # Query the API to get the current IP address NEW_IP=$(curl -s https://api.ipify.org) I found this site very slow to respond. It could be timing out with an empty result. OTOH the URL used in the get_ip_address function is rapid, but you don't call that function. sleep 2 Yes, I notice it, it take upwards 10sec to get an IP and sometimes I get a timeout, I increases "sleep 15" hopefully it will help. # Compare the new IP address with the old one if [[ "$NEW_IP" != "$OLD_IP" ]]; then echo "Your IP address has changed to $NEW_IP" # Send an email notification echo "New IP address: $NEW_IP" | mailto -s "IP address change" $EMAIL # Allow overwriting of the file set +o noclobber # Update the old IP address in the file # printf "%s" "$NEW_IP" > "$IP_FILE" echo -n "$NEW_IP" > "$IP_FILE" # Restore the noclobber option set -o noclobber You don't need to play with the noclobber option, just use >| for redirection, which will always overwrite the file. Thanks for the pointer. else echo "Your IP address is still $OLD_IP" fi
Re: [gentoo-user] ip_change_notifier - empty IP address
On Tue, 27 Jun 2023 10:34:22 -0600, the...@sys-concept.com wrote: > I run this little script to notify me when the IP changes. However at > time to time the file: "old_ip.txt" is being populated with an empty > line "no IP address" > > What could be causing it? > > > #!/bin/bash > > # Replace "YOUR_EMAIL" with your actual email address > EMAIL="your_em...@gmail.com" > > # File to store the old IP address > IP_FILE="/home/fd/business/scripts/old_ip.txt" > > # Read the old IP address from the file > OLD_IP=$(cat "$IP_FILE") > > # Function to retrieve the IP address > get_ip_address() { > local ip_address > ip_address=$(curl -s https://ifconfig.me/ip) > echo "$ip_address" > } > > # Query the API to get the current IP address > NEW_IP=$(curl -s https://api.ipify.org) I found this site very slow to respond. It could be timing out with an empty result. OTOH the URL used in the get_ip_address function is rapid, but you don't call that function. > > sleep 2 > > # Compare the new IP address with the old one > if [[ "$NEW_IP" != "$OLD_IP" ]]; then > echo "Your IP address has changed to $NEW_IP" > > # Send an email notification > echo "New IP address: $NEW_IP" | mailto -s "IP address change" > $EMAIL > > # Allow overwriting of the file > set +o noclobber > > # Update the old IP address in the file > # printf "%s" "$NEW_IP" > "$IP_FILE" > echo -n "$NEW_IP" > "$IP_FILE" > > # Restore the noclobber option > set -o noclobber You don't need to play with the noclobber option, just use >| for redirection, which will always overwrite the file. > > else > echo "Your IP address is still $OLD_IP" > fi > > -- Neil Bothwick Linux like wigwam. No windows, no gates, Apache inside. pgpW1QIVucn30.pgp Description: OpenPGP digital signature
[gentoo-user] ip_change_notifier - empty IP address
I run this little script to notify me when the IP changes. However at time to time the file: "old_ip.txt" is being populated with an empty line "no IP address" What could be causing it? #!/bin/bash # Replace "YOUR_EMAIL" with your actual email address EMAIL="your_em...@gmail.com" # File to store the old IP address IP_FILE="/home/fd/business/scripts/old_ip.txt" # Read the old IP address from the file OLD_IP=$(cat "$IP_FILE") # Function to retrieve the IP address get_ip_address() { local ip_address ip_address=$(curl -s https://ifconfig.me/ip) echo "$ip_address" } # Query the API to get the current IP address NEW_IP=$(curl -s https://api.ipify.org) sleep 2 # Compare the new IP address with the old one if [[ "$NEW_IP" != "$OLD_IP" ]]; then echo "Your IP address has changed to $NEW_IP" # Send an email notification echo "New IP address: $NEW_IP" | mailto -s "IP address change" $EMAIL # Allow overwriting of the file set +o noclobber # Update the old IP address in the file # printf "%s" "$NEW_IP" > "$IP_FILE" echo -n "$NEW_IP" > "$IP_FILE" # Restore the noclobber option set -o noclobber else echo "Your IP address is still $OLD_IP" fi -- Thelma
Re: [gentoo-user] disable password wait time
the...@sys-concept.com wrote: > On 6/27/23 00:05, Dale wrote: >> the...@sys-concept.com wrote: >>> I forgot, how to disable password wait time 10min when wrong password >>> is entered. >>> Where is the setting? >>> >>> >>> >> >> >> Check here: >> >> /etc/login.defs >> >> Hope that helps. >> >> Dale >> >> :-) :-) > > I'm not sure if it is the correct but setting in: > /etc/security/faillock.conf > deny = 0 > > Solved the problem. > > When I was searching some more after my reply, I noticed it is in different places depending on what you use for security/passwords. I think I use pam here. You may be using something else. Oddly, I don't recall seeing the one you said worked anywhere tho. So, it appears there is quite a few places that setting can be, even if google doesn't know it. lol Glad you got it working. That's what matters. Dale :-) :-)
Re: [gentoo-user] disable password wait time
On 6/27/23 00:05, Dale wrote: the...@sys-concept.com wrote: I forgot, how to disable password wait time 10min when wrong password is entered. Where is the setting? Check here: /etc/login.defs Hope that helps. Dale :-) :-) I'm not sure if it is the correct but setting in: /etc/security/faillock.conf deny = 0 Solved the problem.
Re: [gentoo-user] disable password wait time
the...@sys-concept.com wrote: > I forgot, how to disable password wait time 10min when wrong password > is entered. > Where is the setting? > > > Check here: /etc/login.defs Hope that helps. Dale :-) :-)