Skip to content

Instantly share code, notes, and snippets.

@eggplants
Last active July 16, 2019 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eggplants/19408b36d125c5b57f83e85682bee04a to your computer and use it in GitHub Desktop.
Save eggplants/19408b36d125c5b57f83e85682bee04a to your computer and use it in GitHub Desktop.
cat exist.csv |grep "status=>\"200\""|grep -oP "url=>\".*?\""|sed -e "s/\"//g" -e "s/url=>//g"
require "open-uri"
require "date"
p=[]
data=`ls -la /www|awk '$0=$9'|grep -oP "s181[0-9]+"`
data.scan(/^s[0-9]+$/).each{|i|["https","http"].each{|prot|
begin
print url="#{prot}://www.u.tsukuba.ac.jp/~#{i}"
s=open(url).status[0]
rescue
s=$!
end
print "\r"
p<<[ :status=>s, :id=>"20#{i.scan(/[0-9]+/)[0]}", :url=>url, :time=>DateTime.now.strftime("%Y-%m-%d")]
}}
File.open("exist.csv","w"){|file|p.each{|i|
file.puts i.join(" ")
}}
require "open-uri"
require "date"
p=[]
data=`ls -la /www|awk '$0=$9'|grep -oP "s[0-9]+"`
data.scan(/^s[0-9]+$/).each{|i|["www","cgi"].each{|serv|["https","http"].each{|prot|
begin
print url="#{prot}://#{serv}.u.tsukuba.ac.jp/~#{i}"
s=open(url).status[0]
rescue
s=$!
end
print "\r"
p<<[ :status=>s, :id=>"20#{i.scan(/[0-9]+/)[0]}", :url=>url, :time=>DateTime.now.strftime("%Y-%m-%d")]
}}}
File.open("exist.csv","w"){|file|p.each{|i|
file.puts i.join(" ")
}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment