我写了一个bash脚本,它从www.vpnbook.com/freevpn读取用户名和密码,然后巧妙地自动化vpn。以下是代码段。我希望Stack社区隐藏我的xterm -e -hold ./Overflow.sh
我试过nohup并申请&这根本不起作用。我希望xterm窗口对用户不可见。用户不应该知道发生了什么,即使他关闭了终端窗口,任务也不应该结束。
以下是我的代码:(贡献给我心爱的Stack社区)
Overflow.sh
#!/usr/bin/expect -f
spawn openvpn vpnbook-ca1-udp25000.ovpn
#spawn ssh aspen
set password [lindex $argv 1]
expect "Enter Auth Username: "
send "vpnbook\r"
expect "Enter Auth Password: "
send "he2qv5h\r";
interact
Web-Scraper.sh
#!/bin/bash
clear
echo "Copyright of KatworX© Tech. Developed by Arjun Singh Kathait and Debugged by the ☆Stack Overflow Community☆"
echo
# Creating a Spinner Animation.
spinner()
{
local pid=$!
local delay=0.75
local spinstr='|/-\'
while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
local temp=${spinstr#?}
printf " [%c] " "$spinstr"
local spinstr=$temp${spinstr%"$temp"}
sleep $delay
printf "\b\b\b\b\b\b"
done
printf " \b\b\b\b"
}
ProgMeter()
{
function ProgressBar
{
let _progress=(${1}*100/${2}*100)/100
let _done=(${_progress}*4)/10
let _left=40-$_done
# Building the String length of the Progress Meter
_fill=$(printf "%${_done}s")
_empty=$(printf "%${_left}s")
# 1.2.1 Output example:
# 1.2.1.1 Progress : [████████████████████████████████████████] 100%
printf "\rProcessing Dump : [${_fill// /█}${_empty// /-}] ${_progress}%%"
}
# Variables
_start=1
# This accounts as the "totalState" variable for the ProgressBar function
_end=100
# Proof of concept
for number in $(seq ${_start} ${_end})
do
sleep 0.1
ProgressBar ${number} ${_end}
done
echo -e "\n"
echo -e "Succesfully Altered the IP."
echo
}
#echo -e "Fetching Network Information"
sleep 5 & spinner
python StackReader.py
echo
w3m https://www.vpnbook.com/freevpn -dump > Log.txt & ProgMeter
sleep 2
# `Password Extracter
i=0
while read -r line; do
# changed ++i == 15 to 3
((++i == 44)) || continue
arr=($line)
#changed arr[n]
Pass="${arr[2]}"
echo $Pass
break
done < /root/Desktop/Pit-Wolf/Log.txt
# End of Password Extracter`
#VPNBook is a Virtual Private Network provider that uses an 3ncrypted connection to alternate the user's original IP address. Although it is still unknown who is behind this service and how it receives it's funding, it is still free to use and it was reviewed in a special article of the PC Magazine, where its said that the service "HAS CERTAIN FUNCTIONALITY FLAWS, BUT IS GOOD FOR A FREE VPN SERVICE". It was also reviewed by "BestVPN portal".
echo -ne '\007'
chmod +x Overflow.sh
xterm -hold -e ./Overflow.sh
另外,有没有办法将$Pass
的值传递给Overflow.sh ???
另请注意,我从同一文件夹中的网站下载了4个文件。
任何帮助都会得到我在堆栈社区的兄弟姐妹的赏识。(除了主持人)
答案 0 :(得分:0)
尝试使用:
./Overflow.sh &`
希望解决问题。