Skip to main content
Changed title and example in light of clarification of purpose
Source Link
200_success
  • 145.6k
  • 22
  • 191
  • 481

Extracting timeperformance statistics from FTP session transcript

I've borrowed and written the following code to output the disconnect time. All works well but I'm curious as to how I could tighten/ shorten the code. If anyone feels like having some fun then I'd love to see what can be done. Be a learning lesson for me.

OutputExcerpt of input:

ftp> !:--- FTP commands below here ---
ftp> lcd C:\Utilities\Performance_Testing\
\Utilities\Performance_Testing\: File not found 
Verbose mode On .
ftp> verbose
binary
200 Switching to Binary mode.
ftp> put "test_file_5M.bin"
200 PORT command successful.
150 Ok to send data.
226 File receive OK.
ftp: 5242880 bytes sent in Seconds Kbytes/sec.
ftp> 44.81117.00disconnect
221 Goodbye.
ftp> bye 

Code:

#Obtain UT external put value.
ut1intput=$(awk '
  NR==70 {
    for(i=1;i<=NF;i++) { 
      if($i=="ftp>") {
        sub(/disconnect/, "", $(i+1));
        print $(i+1)
      }
    }
  }' filename.txt)

utintputvalue=`echo $ut1intput | awk -F. '{print $2"."$3}'| sed  's/^..//'`

Output:

UT external put valueutintputvalue is 1220117.9800

Extracting time from FTP session transcript

I've borrowed and written the following code to output the disconnect time. All works well but I'm curious as to how I could tighten/ shorten the code. If anyone feels like having some fun then I'd love to see what can be done. Be a learning lesson for me.

Output:

ftp> !:--- FTP commands below here ---
ftp> lcd C:\Utilities\Performance_Testing\
\Utilities\Performance_Testing\: File not found 
Verbose mode On .
ftp> verbose
binary
200 Switching to Binary mode.
ftp> put "test_file_5M.bin"
200 PORT command successful.
150 Ok to send data.
226 File receive OK.
ftp: 5242880 bytes sent in Seconds Kbytes/sec.
ftp> 44.81117.00disconnect
221 Goodbye.
ftp> bye 

Code:

#Obtain UT external put value.
ut1intput=$(awk '
  NR==70 {
    for(i=1;i<=NF;i++) { 
      if($i=="ftp>") {
        sub(/disconnect/, "", $(i+1));
        print $(i+1)
      }
    }
  }' filename.txt)

utintputvalue=`echo $ut1intput | awk -F. '{print $2"."$3}'| sed  's/^..//'`

Output:

UT external put value is 1220.98

Extracting performance statistics from FTP session transcript

I've borrowed and written the following code to output the disconnect time. All works well but I'm curious as to how I could tighten/ shorten the code. If anyone feels like having some fun then I'd love to see what can be done. Be a learning lesson for me.

Excerpt of input:

ftp> !:--- FTP commands below here ---
ftp> lcd C:\Utilities\Performance_Testing\
\Utilities\Performance_Testing\: File not found 
Verbose mode On .
ftp> verbose
binary
200 Switching to Binary mode.
ftp> put "test_file_5M.bin"
200 PORT command successful.
150 Ok to send data.
226 File receive OK.
ftp: 5242880 bytes sent in Seconds Kbytes/sec.
ftp> 44.81117.00disconnect
221 Goodbye.
ftp> bye 

Code:

#Obtain UT external put value.
ut1intput=$(awk '
  NR==70 {
    for(i=1;i<=NF;i++) { 
      if($i=="ftp>") {
        sub(/disconnect/, "", $(i+1));
        print $(i+1)
      }
    }
  }' filename.txt)

utintputvalue=`echo $ut1intput | awk -F. '{print $2"."$3}'| sed  's/^..//'`

Output:

utintputvalue is 117.00
edited title; edited tags
Link
200_success
  • 145.6k
  • 22
  • 191
  • 481

Optimizing AWK script Extracting time from FTP session transcript

deleted 22 characters in body; edited title
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

Optimizing AWK script. Looking for an optimized example

I've borrowed and written the following code to output the disconnect time. All works well but I'm curious as to how I could tighten/ shorten the code. If anyone feels like having some fun then I'd love to see what can be done. Be a learning lesson for me.

Cheers in advance.

Output:

ftp> !:--- FTP commands below here ---
ftp> lcd C:\Utilities\Performance_Testing\
\Utilities\Performance_Testing\: File not found 
Verbose mode On .
ftp> verbose
binary
200 Switching to Binary mode.
ftp> put "test_file_5M.bin"
200 PORT command successful.
150 Ok to send data.
226 File receive OK.
ftp: 5242880 bytes sent in Seconds Kbytes/sec.
ftp> 44.81117.00disconnect
221 Goodbye.
ftp> bye 

Code:

#Obtain UT external put value.
ut1intput=$(awk '
  NR==70 {
    for(i=1;i<=NF;i++) { 
      if($i=="ftp>") {
        sub(/disconnect/, "", $(i+1));
        print $(i+1)
      }
    }
  }' filename.txt)

utintputvalue=`echo $ut1intput | awk -F. '{print $2"."$3}'| sed  's/^..//'`

Output:

UT external put value is 1220.98

AWK script. Looking for an optimized example

I've borrowed and written the following code to output the disconnect time. All works well but I'm curious as to how I could tighten/ shorten the code. If anyone feels like having some fun then I'd love to see what can be done. Be a learning lesson for me.

Cheers in advance.

Output:

ftp> !:--- FTP commands below here ---
ftp> lcd C:\Utilities\Performance_Testing\
\Utilities\Performance_Testing\: File not found 
Verbose mode On .
ftp> verbose
binary
200 Switching to Binary mode.
ftp> put "test_file_5M.bin"
200 PORT command successful.
150 Ok to send data.
226 File receive OK.
ftp: 5242880 bytes sent in Seconds Kbytes/sec.
ftp> 44.81117.00disconnect
221 Goodbye.
ftp> bye 

Code:

#Obtain UT external put value.
ut1intput=$(awk '
  NR==70 {
    for(i=1;i<=NF;i++) { 
      if($i=="ftp>") {
        sub(/disconnect/, "", $(i+1));
        print $(i+1)
      }
    }
  }' filename.txt)

utintputvalue=`echo $ut1intput | awk -F. '{print $2"."$3}'| sed  's/^..//'`

Output:

UT external put value is 1220.98

Optimizing AWK script

I've borrowed and written the following code to output the disconnect time. All works well but I'm curious as to how I could tighten/ shorten the code. If anyone feels like having some fun then I'd love to see what can be done. Be a learning lesson for me.

Output:

ftp> !:--- FTP commands below here ---
ftp> lcd C:\Utilities\Performance_Testing\
\Utilities\Performance_Testing\: File not found 
Verbose mode On .
ftp> verbose
binary
200 Switching to Binary mode.
ftp> put "test_file_5M.bin"
200 PORT command successful.
150 Ok to send data.
226 File receive OK.
ftp: 5242880 bytes sent in Seconds Kbytes/sec.
ftp> 44.81117.00disconnect
221 Goodbye.
ftp> bye 

Code:

#Obtain UT external put value.
ut1intput=$(awk '
  NR==70 {
    for(i=1;i<=NF;i++) { 
      if($i=="ftp>") {
        sub(/disconnect/, "", $(i+1));
        print $(i+1)
      }
    }
  }' filename.txt)

utintputvalue=`echo $ut1intput | awk -F. '{print $2"."$3}'| sed  's/^..//'`

Output:

UT external put value is 1220.98
Source Link
Loading