From 2f2f648492bc0e24efc11738ab0952b4fe040b03 Mon Sep 17 00:00:00 2001 From: aaron <462826@qq.com> Date: Fri, 7 May 2021 16:38:20 +0800 Subject: [PATCH] update demo scripts --- demo/lang/ruby/1_string_match.rb | 16 +++++++--------- demo/lang/ruby/2_webpage_extract.rb | 19 +++++++++---------- demo/lang/ruby/3_http_inteface_call.rb | 14 ++++++-------- demo/lang/shell/1_string_match.sh | 9 +++------ demo/lang/shell/2_webpage_extract.sh | 9 +++------ demo/lang/shell/3_http_inteface_call.sh | 7 ++----- demo/lang/tcl/1_string_match.tl | 10 ++++------ demo/lang/tcl/2_webpage_extract.tl | 16 +++++++--------- demo/lang/tcl/3_http_inteface_call.tl | 12 +++++------- 9 files changed, 46 insertions(+), 66 deletions(-) diff --git a/demo/lang/ruby/1_string_match.rb b/demo/lang/ruby/1_string_match.rb index 5bd3e97b..a74c0cd8 100755 --- a/demo/lang/ruby/1_string_match.rb +++ b/demo/lang/ruby/1_string_match.rb @@ -1,18 +1,16 @@ #!/usr/bin/env ruby =begin -[case] + title=check string matches pattern cid=0 pid=0 -[group] - 1. exactly match >> hello - 2. regular expression match >> `1\d{10}` - 3. format string match >> `%s%d` +1. exactly match >> hello +2. regular expression match >> `1\d{10}` +3. format string match >> `%s%d` -[esac] =end -print(">> hello\n"); -print(">> 13905120512\n"); -print(">> abc123\n"); \ No newline at end of file +print("hello\n"); +print("13905120512\n"); +print("abc123\n"); diff --git a/demo/lang/ruby/2_webpage_extract.rb b/demo/lang/ruby/2_webpage_extract.rb index 27232b7b..5dba7442 100755 --- a/demo/lang/ruby/2_webpage_extract.rb +++ b/demo/lang/ruby/2_webpage_extract.rb @@ -1,25 +1,24 @@ #!/usr/bin/env ruby + =begin -[case] + title=extract content from webpage cid=0 pid=0 -[group] - 1. Load web page from url http://xxx - 2. Retrieve img element zt-logo.png in html - 3. Check img exist >> `.*zt-logo.png` +1. Load web page from url http://xxx +2. Retrieve img element zt-logo.png in html +3. Check img exist >> `.*zt-logo.png` -[esac] -=enddf +=end require "open-uri" -uri = 'http://pms.zentao.net/user-login.html' +uri = 'http://max.demo.zentao.net/user-login-Lw==.html' html = nil open(uri) do |http| html = http.read end -elem = html.match(//).captures -puts '>> ' + elem[0] +elem = html.match(//).captures +puts ""+elem[0] diff --git a/demo/lang/ruby/3_http_inteface_call.rb b/demo/lang/ruby/3_http_inteface_call.rb index 729e6827..630fb7c9 100755 --- a/demo/lang/ruby/3_http_inteface_call.rb +++ b/demo/lang/ruby/3_http_inteface_call.rb @@ -1,26 +1,24 @@ #!/usr/bin/env ruby =begin -[case] + title=check remote interface response cid=0 pid=0 -[group] - 1. Send a request to interface http://xxx - 2. Retrieve sessionID field from response json - 3. Check its format >> `^[a-z0-9]{26}` +1. Send a request to interface http://xxx +2. Retrieve sessionID field from response json +3. Check its format >> `^[a-z0-9]{26}` -[esac] =end require "open-uri" require "json" -uri = 'http://pms.zentao.net/?mode=getconfig' +uri = 'http://max.demo.zentao.net/pms/?mode=getconfig' html = nil open(uri) do |http| html = http.read end json = JSON.parse(html) # need json library (gem install json) -puts '>> ' + json['sessionID'] \ No newline at end of file +puts json['sessionID'] diff --git a/demo/lang/shell/1_string_match.sh b/demo/lang/shell/1_string_match.sh index e79b1985..d121abe1 100755 --- a/demo/lang/shell/1_string_match.sh +++ b/demo/lang/shell/1_string_match.sh @@ -1,22 +1,19 @@ #!/usr/bin/env bash :<> hello 2. regular expression match >> `1[0-9]{10}` 3. format string match >> `%s%d` -[esac] ! str="abc123" -echo ">> hello" -echo ">> 13905120512" -echo ">> abc123" +echo "hello" +echo "13905120512" +echo "abc123" diff --git a/demo/lang/shell/2_webpage_extract.sh b/demo/lang/shell/2_webpage_extract.sh index 74c5d92a..24a5041e 100755 --- a/demo/lang/shell/2_webpage_extract.sh +++ b/demo/lang/shell/2_webpage_extract.sh @@ -1,21 +1,18 @@ #!/usr/bin/env bash :<> `.*zt-logo.png` -[esac] ! -resp=$(curl -s http://pms.zentao.net/user-login.html) # apt-get install curl if needed -elem=`echo $resp | grep -o "]*src='[^']*'" | grep -o "[^']*.png"` +resp=$(curl -s http://max.demo.zentao.net/user-login-Lw==.html) # apt-get install curl if needed +elem=`echo $resp | grep -o ']*src="[^"]*"'` -echo ">> $elem" +echo "$elem" diff --git a/demo/lang/shell/3_http_inteface_call.sh b/demo/lang/shell/3_http_inteface_call.sh index bed70008..4c44abe0 100755 --- a/demo/lang/shell/3_http_inteface_call.sh +++ b/demo/lang/shell/3_http_inteface_call.sh @@ -1,21 +1,18 @@ #!/usr/bin/env bash :<> `^[a-z0-9]{26}` -[esac] ! -resp=$(curl -s 'http://pms.zentao.net/?mode=getconfig') # apt-get install curl if needed +resp=$(curl -s 'http://max.demo.zentao.net/pms/?mode=getconfig') # apt-get install curl if needed elem=`echo $resp | grep -o '"sessionID":"[^"]*"' | sed 's/^.*:"//g' | sed 's/"//g'` -echo ">> $elem" +echo "$elem" diff --git a/demo/lang/tcl/1_string_match.tl b/demo/lang/tcl/1_string_match.tl index 7a040663..80fd259f 100755 --- a/demo/lang/tcl/1_string_match.tl +++ b/demo/lang/tcl/1_string_match.tl @@ -1,18 +1,16 @@ #!/usr/bin/env tclsh set case { -[case] + title=check string matches pattern cid=0 pid=0 -[group] 1. exactly match >> hello 2. regular expression match >> `1\d{10}` 3. format string match >> `%s%d` -[esac] } -puts ">> hello" -puts ">> 13905120512" -puts ">> abc123" \ No newline at end of file +puts "hello" +puts "13905120512" +puts "abc123" diff --git a/demo/lang/tcl/2_webpage_extract.tl b/demo/lang/tcl/2_webpage_extract.tl index 40c309b2..9bdc26e6 100755 --- a/demo/lang/tcl/2_webpage_extract.tl +++ b/demo/lang/tcl/2_webpage_extract.tl @@ -1,24 +1,22 @@ #!/usr/bin/env tclsh set case { -[case] + title=extract content from webpage cid=0 pid=0 -[group] - 1. Load web page from url http://xxx - 2. Retrieve img element zt-logo.png in html - 3. Check img exist >> `.*zt-logo.png` +1. Load web page from url http://xxx +2. Retrieve img element zt-logo.png in html +3. Check img exist >> `.*zt-logo.png` -[esac] } package require http -set url http://pms.zentao.net/user-login.html +set url http://max.demo.zentao.net/user-login-Lw==.html set http [::http::geturl $url] set html [::http::data $http] -regexp -- {} $html match elem -puts ">> $elem" \ No newline at end of file +regexp -- {} $html match elem +puts "$elem" diff --git a/demo/lang/tcl/3_http_inteface_call.tl b/demo/lang/tcl/3_http_inteface_call.tl index 8667151b..dfb9abe2 100755 --- a/demo/lang/tcl/3_http_inteface_call.tl +++ b/demo/lang/tcl/3_http_inteface_call.tl @@ -1,26 +1,24 @@ #!/usr/bin/env tclsh set case { -[case] + title=check remote interface response cid=0 pid=0 -[group] - 1. Send a request to interface http://xxx - 2. Retrieve sessionID field from response json + 1. Send a request to interface http://xxx + 2. Retrieve sessionID field from response json 3. Check its format >> `^[a-z0-9]{26}` -[esac] } package require http package require json -set url http://pms.zentao.net/?mode=getconfig +set url http://max.demo.zentao.net/pms/?mode=getconfig set http [::http::geturl $url] set jsonStr [::http::data $http] # need json library, you may use ActiveTcl set jsonObj [json::json2dict $jsonStr] -puts ">> [dict get $jsonObj sessionID]" \ No newline at end of file +puts "[dict get $jsonObj sessionID]" -- GitLab