LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-22-2024, 02:09 AM   #16
Jason.nix
Member
 
Registered: Feb 2023
Posts: 601

Original Poster
Rep: Reputation: 10

Quote:
Originally Posted by pan64 View Post
does it solve that hanging issue?
what is the purpose of that cut and sed?
So Start and Restart are not printed. Therefore it is no ok. Otherwise where should it be printed to? How do you execute this script at all?
Why do you need two threads for the same issue?
Hi,
As I said, this thread has nothing to do with the thread question.
 
Old 09-22-2024, 02:42 AM   #17
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,582
Blog Entries: 4

Rep: Reputation: 3878Reputation: 3878Reputation: 3878Reputation: 3878Reputation: 3878Reputation: 3878Reputation: 3878Reputation: 3878Reputation: 3878Reputation: 3878Reputation: 3878
Quote:
Originally Posted by Jason.nix View Post
Why is the Start or Restart message not printed?
It was not printing the message because it did not loop and went through the conditional just once while Tor was working.

Code:
#!/bin/sh

PATH=/usr/bin:/bin

url='http://checkip.amazonaws.com/'

echo "Start"

while true
do
	var=$(torify 2> /dev/null wget $url -O - -o /dev/null)
	if test -n "$var"
	then
		echo "Running"
		apt update -q -y
        	apt upgrade -q -y --download-only
	else
		echo "Restarting"
	        systemctl restart tor
	fi
        sleep 900
done
See "man sh" or https://www.learnshell.org/

Last edited by Turbocapitalist; 09-22-2024 at 12:43 PM. Reason: typo
 
Old 09-22-2024, 12:28 PM   #18
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 23,009

Rep: Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627Reputation: 7627
Quote:
Originally Posted by Jason.nix View Post
Hi,
As I said, this thread has nothing to do with the thread question.
it is not an answer at all. But anyway, forget that last one, and answer the others.
 
1 members found this post helpful.
Old 09-24-2024, 03:49 AM   #19
Jason.nix
Member
 
Registered: Feb 2023
Posts: 601

Original Poster
Rep: Reputation: 10
Quote:
Originally Posted by Turbocapitalist View Post
It was not printing the message because it did not loop and went through the conditional just once while Tor was working.

Code:
#!/bin/sh

PATH=/usr/bin:/bin

url='http://checkip.amazonaws.com/'

echo "Start"

while true
do
	var=$(torify 2> /dev/null wget $url -O - -o /dev/null)
	if test -n "$var"
	then
		echo "Running"
		apt update -q -y
        	apt upgrade -q -y --download-only
	else
		echo "Restarting"
	        systemctl restart tor
	fi
        sleep 900
done
See "man sh" or https://www.learnshell.org/
Hello,
Thank you so much for your reply.
I created a script file like below:
Code:
#!/bin/bash

VAR=$(torify 2> /dev/null wget http://checkip.amazonaws.com/ -O - -o /dev/null | cut -d" " -f6 | sed 's/<\/body><\/html>//');

while :
do
	if [[ $VAR ]]
	then
	echo "OK";
	break
	else
	 echo "Restart";
         /usr/bin/systemctl restart tor
         sleep 3600;
	 VAR=$(torify 2> /dev/null wget http://checkip.amazonaws.com/ -O - -o /dev/null | cut -d" " -f6 | sed 's/<\/body><\/html>//');
	fi
done
This script verifies that Tor is working properly (connected to a node). I have written a crontab as follows:
Code:
0 22 * * * root /usr/bin/bash /etc/Script.sh
But:
Code:
# ss -tupln | grep 9050
tcp   LISTEN 0      4096     172.20.2.54:9050       0.0.0.0:*    users:(("tor",pid=524735,fd=6))   
#
# httping -x 172.20.2.54:9050 -5 -g http://www.google.com
PING www.google.com:80 (/):
socks5connect: command reply receive failure
Does my script not run long enough to connect the Tor to a node?
 
  


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
LXer: Tor exit nodes face unusual activity, is Tor being raided or under hack attack? LXer Syndicated Linux News 0 12-23-2014 01:03 AM
LXer: How To Set Up A TOR Middlebox Routing All VirtualBox Virtual Machine Traffic Over The TOR Netw LXer Syndicated Linux News 0 02-08-2012 12:30 PM
LXer: Tor Browser Bundle-Tor Goes Portable LXer Syndicated Linux News 1 09-02-2011 03:29 AM
TOR: traffic between my workstation TOR entry point really not encrypted..? john99 Incognito 3 11-11-2009 02:06 AM
TOR-there seems to be no tor.pkg- what now? me-$-on Slackware 5 06-06-2008 12:08 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:14 PM.

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
Open Source Consulting | Domain Registration