Run command once a port is listening #69

Open
opened 2025-03-07 17:40:07 +01:00 by Benjamin_Loison · 7 comments

Related to #38.

Related to #38.
Author
Owner
Would help [Benjamin_Loison/openssh/issues/68](https://salsa.debian.org/Benjamin_Loison/openssh/-/issues/68).
Author
Owner

DuckDuckGo search Linux run command once port listen.

DuckDuckGo search *Linux run command once port listen*.
Author
Owner

#44 could help but I am not root on the server I have in mind.

tail /var/log/auth.log
tail: cannot open '/var/log/auth.log' for reading: Permission denied
#44 could help but I am not `root` on the server I have in mind. ```bash tail /var/log/auth.log ``` ``` tail: cannot open '/var/log/auth.log' for reading: Permission denied ```
Author
Owner
netstat -tulpn | grep 2224
Output:
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 127.0.0.1:2224          0.0.0.0:*               LISTEN      -                   
tcp6       0      0 ::1:2224                :::*                    LISTEN      -
netstat -tulpn | grep 2250
Output:
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
```bash netstat -tulpn | grep 2224 ``` <details> <summary>Output:</summary> ``` (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) tcp 0 0 127.0.0.1:2224 0.0.0.0:* LISTEN - tcp6 0 0 ::1:2224 :::* LISTEN - ``` </details> ```bash netstat -tulpn | grep 2250 ``` <details> <summary>Output:</summary> ``` (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) ``` </details>
Author
Owner

DuckDuckGo and Google search run command on netstat update.

DuckDuckGo and Google search *run command on netstat update*.
Author
Owner
inotifywait -e modify /dev/tcp/127.0.0.1/22
Output:
Setting up watches.
Couldn't watch /dev/tcp/127.0.0.1/22: No such file or directory

Source: Benjamin-Loison/LemnosLife-Client/issues/85#issuecomment-1636544466

```bash inotifywait -e modify /dev/tcp/127.0.0.1/22 ``` <details> <summary>Output:</summary> ``` Setting up watches. Couldn't watch /dev/tcp/127.0.0.1/22: No such file or directory ``` </details> Source: [Benjamin-Loison/LemnosLife-Client/issues/85#issuecomment-1636544466](https://github.com/Benjamin-Loison/LemnosLife-Client/issues/85#issuecomment-1636544466)
Author
Owner
Bash script:
PORT=2250
 KEY=CENSORED
MESSAGE="`hostname`:$PORT is back online!"
NUMBER_OF_SECONDS_BETWEEN_EACH_TRY=60
while ! (echo -n > /dev/tcp/localhost/$PORT) 2> /dev/null
do
    date
    sleep $NUMBER_OF_SECONDS_BETWEEN_EACH_TRY
done | tee -a logs.txt
curl -G https://lemnoslife.com/CENSORED/notify.php --data-urlencode "message=$MESSAGE" -d key=$KEY

one second and exponential delays do not seem appropriate.

<details> <summary>Bash script:</summary> ```bash PORT=2250 KEY=CENSORED MESSAGE="`hostname`:$PORT is back online!" NUMBER_OF_SECONDS_BETWEEN_EACH_TRY=60 while ! (echo -n > /dev/tcp/localhost/$PORT) 2> /dev/null do date sleep $NUMBER_OF_SECONDS_BETWEEN_EACH_TRY done | tee -a logs.txt curl -G https://lemnoslife.com/CENSORED/notify.php --data-urlencode "message=$MESSAGE" -d key=$KEY ``` </details> one second and exponential delays do not seem appropriate.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Benjamin_Loison/linux#69
No description provided.