Saturday, May 22, 2021

System information: kernel and OS

Script

#!/usr/local/bin/python3.5

import subprocess

universal = "uname"
universal_argument = "-a"

print("Extracting system information with the command: ", universal, universal_argument)
print()
subprocess.call([universal, universal_argument])
print()
print()


Execution

Extracting system information with the command:  uname -a

Linux ip-172-31-24-12.us-west-2.compute.internal 3.10.0-514.el7.x86_64 #1 SMP Wed Oct 19 11:24:13 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux






Basic file open procedures

Script

Method 1
#!/usr/local/bin/python3.7

f = open('rahul-dravid.txt', 'r')

for line in f:
    print(line.strip())
f.close

Method 2
#!/usr/local/bin/python3.7

with open('rahul-dravid.txt') as f:
    for line in f:
        print(line.strip())

Background

KSuryaSJC-TBMBP:Python-scripts kiran.surya$ cat rahul-dravid.txt
Adelaide Test 2003. India versus Australia. Australia 556. India, through a mammoth partnership of 303
between Dravid and Laxman, recover from 85 for 4 to 477 for 7. Dravid is on strike on 199. The first
ball of the last and 90th over of Day three is being bowled. Dravid hits the ball to deep cover. He has
two choices: a) take a single, complete his double century but expose the tailender Anil Kumble to five
deliveries before the end of the day's play b) refuse to take the easy single, defend the next five balls
or risk taking a single off the last ball of the day thereby protecting Anil Kumble. Dravid refuses the
single that would take him to 200, and cannot force the last ball of the day for a single. Stranded on 199
not out overnight and have to endure a sleepless night. Never mind; team interests come first, ahead of
personal milestones. That's Dravid for you !!!
KSuryaSJC-TBMBP:Python-scripts kiran.surya$

Execution

Adelaide Test 2003. India versus Australia. Australia 556. India, through a mammoth partnership of 303
between Dravid and Laxman, recover from 85 for 4 to 477 for 7. Dravid is on strike on 199. The first
ball of the last and 90th over of Day three is being bowled. Dravid hits the ball to deep cover. He has
two choices: a) take a single, complete his double century but expose the tailender Anil Kumble to five
deliveries before the end of the day's play b) refuse to take the easy single, defend the next five balls
or risk taking a single off the last ball of the day thereby protecting Anil Kumble. Dravid refuses the
single that would take him to 200, and cannot force the last ball of the day for a single. Stranded on 199
not out overnight and have to endure a sleepless night. Never mind; team interests come first, ahead of
personal milestones. That's Dravid for you !!!








List files in a directory

Script

ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts >
ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts > cat list-files.py
#!/usr/local/bin/python3.5

import subprocess

subprocess.call(["ls", "-altr"])
ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts >


Execution

ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts/Memorable-Tests >
ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts/Memorable-Tests > /Python-scripts/list-files.py
total 8
-rw-r--r--. 1 root root    0 Feb 27 07:02 Kolkata-2001-K10.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 PortofSpain-1976-K02.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Chennai-2008-K15.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Oval-1971-K01.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Madras-1998-K08.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Lords-2014-K17.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Delhi-1999-K09.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Mumbai-2016-K19.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Kanpur-1996-K07.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Adelaide-2003-K12.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Mohali-2010-K16.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Lords-1986-K04.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Kolkata-2005-K13.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Melbourne-1977-K03.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Calcutta-1993-K05.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Perth-2008-K14.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Headingley-2002-K11.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Vishakapatnam-2016-K18.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Ahmedabad-1996-K06.txt
drwxr-xr-x. 3 root root 4096 Feb 27 07:26 ..
drwxr-xr-x. 2 root root 4096 Feb 27 07:38 .
ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts/Memorable-Tests >
ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts/Memorable-Tests >




List files and rename them based on fields

Script

#!/usr/local/bin/python3.5

import time
import os
os.chdir('/Python-scripts/Memorable-Tests')
print(os.getcwd())
print(os.listdir())

for file in os.listdir():
  print(file)
  print(os.path.splitext(file))
  file_name, file_extension = os.path.splitext(file)
  print(file_name)
  print(file_extension)
  print(file_name.split('-'))
  file_venue, file_year, file_number = file_name.split('-')
  print(file_venue)
  print(file_year)
  print(file_number)
  print('{}-{}-{}{}'.format(file_number, file_venue, file_year, file_extension))
  file_number = file_number.strip()[1:]
  print('{}-{}-{}{}'.format(file_number, file_venue, file_year, file_extension))
  new_name = '{}X{}X{}{}'.format(file_number, file_venue, file_year, file_extension)
        os.rename(file, new_name)
  print(new_name)
  print(file_name)
  print("------------------------------------------")

print("Here are the new filenames")
print("==========================")
for file in os.listdir():
  print(file)

print("****************************************************")
print()
print()

print("Oh, oh, those new filenames look ugly.  Let us revert to the old names!!!!!!!!!")
print("Give me ten seconds..........")
print()
time.sleep(10)

for file in os.listdir():
  # print(os.path.splitext(file))
  file_name, file_extension = os.path.splitext(file)
  file_number, file_venue, file_year = file_name.split('X')
  old_name = '{}-{}-K{}{}'.format(file_venue, file_year, file_number, file_extension)
  os.rename(file, old_name)
  # print(old_name)
  # print(file_name)

print("****************************************************")
print()

for file in os.listdir():
  print(file)

print()
print()
print()


Background

ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts/Memorable-Tests > ls -altr
total 8
-rw-r--r--. 1 root root    0 Feb 27 07:02 Kolkata-2001-K10.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 PortofSpain-1976-K02.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Chennai-2008-K15.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Oval-1971-K01.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Madras-1998-K08.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Lords-2014-K17.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Delhi-1999-K09.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Mumbai-2016-K19.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Kanpur-1996-K07.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Adelaide-2003-K12.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Mohali-2010-K16.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Lords-1986-K04.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Kolkata-2005-K13.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Melbourne-1977-K03.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Calcutta-1993-K05.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Perth-2008-K14.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Headingley-2002-K11.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Vishakapatnam-2016-K18.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Ahmedabad-1996-K06.txt
drwxr-xr-x. 2 root root 4096 Feb 27 07:20 .
drwxr-xr-x. 3 root root 4096 Feb 27 07:26 ..
ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts/Memorable-Tests >
ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts/Memorable-Tests >


Execution


/Python-scripts/Memorable-Tests
['Lords-1986-K04.txt', 'Ahmedabad-1996-K06.txt', 'Delhi-1999-K09.txt', 'Kanpur-1996-K07.txt', 'Oval-1971-K01.txt', 'Kolkata-2001-K10.txt', 'Madras-1998-K08.txt', 'Vishakapatnam-2016-K18.txt', 'Chennai-2008-K15.txt', 'Mohali-2010-K16.txt', 'Mumbai-2016-K19.txt', 'Kolkata-2005-K13.txt', 'Melbourne-1977-K03.txt', 'PortofSpain-1976-K02.txt', 'Lords-2014-K17.txt', 'Headingley-2002-K11.txt', 'Perth-2008-K14.txt', 'Adelaide-2003-K12.txt', 'Calcutta-1993-K05.txt']
Lords-1986-K04.txt
('Lords-1986-K04', '.txt')
Lords-1986-K04
.txt
['Lords', '1986', 'K04']
Lords
1986
K04
K04-Lords-1986.txt
04-Lords-1986.txt
04XLordsX1986.txt
Lords-1986-K04
------------------------------------------
Ahmedabad-1996-K06.txt
('Ahmedabad-1996-K06', '.txt')
Ahmedabad-1996-K06
.txt
['Ahmedabad', '1996', 'K06']
Ahmedabad
1996
K06
K06-Ahmedabad-1996.txt
06-Ahmedabad-1996.txt
06XAhmedabadX1996.txt
Ahmedabad-1996-K06
------------------------------------------
Delhi-1999-K09.txt
('Delhi-1999-K09', '.txt')
Delhi-1999-K09
.txt
['Delhi', '1999', 'K09']
Delhi
1999
K09
K09-Delhi-1999.txt
09-Delhi-1999.txt
09XDelhiX1999.txt
Delhi-1999-K09
------------------------------------------

<<<=========== Deleted a number of lines, for brevity ==============>>>


Lords-2014-K17.txt
('Lords-2014-K17', '.txt')
Lords-2014-K17
.txt
['Lords', '2014', 'K17']
Lords
2014
K17
K17-Lords-2014.txt
17-Lords-2014.txt
17XLordsX2014.txt
Lords-2014-K17
------------------------------------------
Headingley-2002-K11.txt
('Headingley-2002-K11', '.txt')
Headingley-2002-K11
.txt
['Headingley', '2002', 'K11']
Headingley
2002
K11
K11-Headingley-2002.txt
11-Headingley-2002.txt
11XHeadingleyX2002.txt
Headingley-2002-K11
------------------------------------------
Perth-2008-K14.txt
('Perth-2008-K14', '.txt')
Perth-2008-K14
.txt
['Perth', '2008', 'K14']
Perth
2008
K14
K14-Perth-2008.txt
14-Perth-2008.txt
14XPerthX2008.txt
Perth-2008-K14
------------------------------------------
Adelaide-2003-K12.txt
('Adelaide-2003-K12', '.txt')
Adelaide-2003-K12
.txt
['Adelaide', '2003', 'K12']
Adelaide
2003
K12
K12-Adelaide-2003.txt
12-Adelaide-2003.txt
12XAdelaideX2003.txt
Adelaide-2003-K12
------------------------------------------
Calcutta-1993-K05.txt
('Calcutta-1993-K05', '.txt')
Calcutta-1993-K05
.txt
['Calcutta', '1993', 'K05']
Calcutta
1993
K05
K05-Calcutta-1993.txt
05-Calcutta-1993.txt
05XCalcuttaX1993.txt
Calcutta-1993-K05
------------------------------------------
Here are the new filenames
==========================
08XMadrasX1998.txt
18XVishakapatnamX2016.txt
15XChennaiX2008.txt
07XKanpurX1996.txt
16XMohaliX2010.txt
19XMumbaiX2016.txt
13XKolkataX2005.txt
03XMelbourneX1977.txt
04XLordsX1986.txt
10XKolkataX2001.txt
02XPortofSpainX1976.txt
17XLordsX2014.txt
11XHeadingleyX2002.txt
06XAhmedabadX1996.txt
14XPerthX2008.txt
12XAdelaideX2003.txt
05XCalcuttaX1993.txt
09XDelhiX1999.txt
01XOvalX1971.txt
****************************************************


Oh, oh, those new filenames look ugly.  Let us revert to the old names!!!!!!!!!
Give me ten seconds..........

****************************************************

Kanpur-1996-K07.txt
Mohali-2010-K16.txt
Mumbai-2016-K19.txt
Kolkata-2005-K13.txt
Melbourne-1977-K03.txt
Lords-1986-K04.txt
Kolkata-2001-K10.txt
PortofSpain-1976-K02.txt
Lords-2014-K17.txt
Headingley-2002-K11.txt
Ahmedabad-1996-K06.txt
Perth-2008-K14.txt
Adelaide-2003-K12.txt
Calcutta-1993-K05.txt
Delhi-1999-K09.txt
Oval-1971-K01.txt
Vishakapatnam-2016-K18.txt
Madras-1998-K08.txt
Chennai-2008-K15.txt





Create a file, add contents and display the file

Script

#!/usr/local/bin/python3.5

bengalurufile_create = open("/Python-scripts/Memorable-Tests/Bangalore-2017-K20.txt","w+")
bengalurufile_create.write("India beat Australia by 75 runs after trailing by 87 runs in the first innings.\n")
bengalurufile_create.write("Cheteshwar Pujara and Ajinkya Rahane revived the situation for India in the second innings.\n")
bengalurufile_create.write("Steven Smith got into trouble with the umpires when he looked up to the pavilion before reviewing the LBW decision.\n")
bengalurufile_create.close()

smithlbw = open('/Python-scripts/Memorable-Tests/Bangalore-2017-K20.txt','r')
print()
print("Filename: ",smithlbw.name)
print("Mode of opening the file: ",smithlbw.mode)
print()
print("------------------------------------------------------------------------------")
print("\n")
print("The file contents are:\n")
print(smithlbw.read())
smithlbw.close()


Before executing the script

kirands-vm.company.com: /Python-scripts >
kirands-vm.company.com: /Python-scripts > ls -altr /Python-scripts/Memorable-Tests/Bangalore*.*
ls: cannot access /Python-scripts/Memorable-Tests/Bangalore*.*: No such file or directory
kirands-vm.company.com: /Python-scripts >


Execution

Filename:  /Python-scripts/Memorable-Tests/Bangalore-2017-K20.txt
Mode of opening the file:  r

------------------------------------------------------------------------------


The file contents are:

India beat Australia by 75 runs after trailing by 87 runs in the first innings.
Cheteshwar Pujara and Ajinkya Rahane revived the situation for India in the second innings.
Steven Smith got into trouble with the umpires when he looked up to the pavilion before reviewing the LBW decision.


After executing the script

kirands-vm.company.com: /Python-scripts >
kirands-vm.company.com: /Python-scripts > cat /Python-scripts/Memorable-Tests/Bangalore-2017-K20.txt
India beat Australia by 75 runs after trailing by 87 runs in the first innings.
Cheteshwar Pujara and Ajinkya Rahane revived the situation for India in the second innings.
Steven Smith got into trouble with the umpires when he looked up to the pavilion before reviewing the LBW decision.
kirands-vm.company.com: /Python-scripts >




Ethernet header / IP / TCP / UDP packet capture and display

Purpose
Generate a Python module that will read the Ethernet Header, TCP packet, IP header, and a UDP Header and extract/display all the detailed information from each of them.  This is being developed to be able to do packet tracing and analysis.

Script
import socket
import struct
import textwrap

TAB_1 = '\t - '
TAB_2 = '\t\t - '
TAB_3 = '\t\t\t - '
TAB_4 = '\t\t\t\t - '

DATA_TAB_1 = '\t '
DATA_TAB_2 = '\t\t '
DATA_TAB_3 = '\t\t\t '
DATA_TAB_4 = '\t\t\t\t '

def main():
conn = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.ntohs(3))
while True:
raw_Data, addr = conn.recvfrom(65536)
dest_mac, src_mac, eth_proto, data = ethernet_frame(raw_data)
print('\n Ethernet Frame: ')
print(TAB_1 + 'Destination: {}, Source: {}, Protocol: {}.format(dest_mac, src_mac, eth_proto)

#8 for IPv4
if eth_proto == 8:
version, header_length, ttl, proto, src, target, data) = ipv4_packet(data)
print(TAB_1 + 'IPv4 Packet: ')
print(TAB_2 + 'Version: {}, Header Length: {}, TTL: {}'.format(version, header_length, ttl))
print(TAB_2 + 'Protocol: {}, Source {}, Target: {}'.format(proto, src, target))

# ICMP
if proto == 1:
icmp_type, code, checksum, data = icmp_packet(data)
print(TAB_1 + 'ICMP Packet: ')
print(TAB_2 + 'Type: {}, Code: {}, Checksum: {}'.format(icmp_type, code, checksum))
print(format_multi_line(DATA_TAB_3, data))

# TCP
elif proto == 6:
src_port, dest_port, sequence, acknowledgement, flag_urg, flag_ack, flag_psh, flag_rst, flag_syn, flag_fin
print(TAB_1 + 'TCP Segment: ')
print(TAB_2 + 'Source Port: {}, Destination Port: {}'.format(src_port, dest_port))
print(TAB_2 + 'Sequence: {}, Acknowledgement: {}'.format(sequence, acknowledgement))
print(TAB_2 + 'Flags: ')
print(TAB_3 + 'URG: {}, ACK: {}, PSH: {}, RST: {}, SYN: {}, FIN: {}'.format(flag_urg, flag_ack, flag_psh, flag_rst, flag_syn, flag_fin))
print(TAB_2 + 'Data: ')
print(format_multi_line(DATA_TAB_3, data))

# UDP
elif proto == 17:
src_port, dest_port, length, data = udp_segment(data)
print(TAB_1 + 'UDP Segment: ')
print(TAB_2 + 'Source Port: {}, Destination Port: {}, Length: {}'.format(src_port, dest_port, length))

# Other
else:
print(TAB_1 + 'Data: ')
print(format_milti_line(DATA_TAB_2, data))


# Unpack Ethernet frame
def ethernet_frame(data):
dest_mac, src_mac, proto = struct.unpack('! 6s 6s H', data[:14])
return get_mac_addr(dest_mac), get_mac_addr(src_mac), socket.htons(proto), data[14:]

# Return properly formatted MAC addresses (like 0A:CE:92:9D:63:14)
def get_mac_addr(bytes_addr):
bytes_str = map('{:02x}'.format, bytes_addr)
mac_addr = ':'.join(bytes_str).upper()
return ':'.join(bytes_str).upper()

# Unpacks IPv4 packet
def ipv4_packet(data):
version_header_length = data[0]
version = version_header_length >> 4
header_length = (version_header_length & 15) * 4
ttl, proto, src, target = struct.unpack('! 8x B B 2x 4s 4s', data[:20])
return version, header_length, ttl, proto, ipv4(src), ipv4(target), data[header_length:]

# Returns properly formatted IPv4 addresses
def ipv4(addr)
return '.'.join(map(str, addr))

# Unpacks ICMP packet
def icmp_packet(data):
icmp_type, code, checksum = struct.unpack('! B B H', data[:4])
return icmp_type, code, checksum, data[4:]

# Unpacks TCP segment
def tcp_segment(data):
(src_port, dest_port, sequence, acknowledgement, offset_reserved_flags) = struct.unpack('! H H L L H', offset = (offset_reserved_flags >> 12) * 4
flag_urg = (offset_reserved_flags & 32) >> 5
flag_ack = (offset_reserved_flags & 16) >> 5
flag_psh = (offset_reserved_flags &  8) >> 5
flag_rst = (offset_reserved_flags &  4) >> 5
flag_syn = (offset_reserved_flags &  2) >> 5
flag_fin = (offset_reserved_flags &  1) >> 5
return src_port, dest_port, sequence, acknowledgement, flag_urg, flag_ack, flag_psh, flag_rst, flag_syn, flag_fin, data[offset:]

# Unpacks UDP segment
def udp_segment(data):
src_port, dest_port, size = struct.unpack('! H H 2x H', data[:8]

# Formats multi-line data
def format_multi_line(prefix, string, size = 80):
size _= len(prefix)
if isinstance(string, bytes):
string = ' '.join(r '\x{:02x}'.format(byte) for byte in string)
if size % 2:
size _+ 1
return '\n'.join([prefix + line for line in textwrap.wrap(string, size)])

Creating, removing directories, renaming files, different display formats

Script
#!/usr/local/bin/python3.5

import os
from datetime import datetime

# print(dir(os))
print(os.getcwd())
os.chdir('/Python-scripts/Memorable-Tests')
print(os.getcwd())
print(os.listdir())
os.mkdir('Victories-over-Australia')
os.makedirs('Victories-over-Australia/Eighties/In-Australia')
os.makedirs('Victories-over-Australia/Eighties/In-India')
os.makedirs('Victories-over-Australia/Nineties/In-Australia')
os.makedirs('Victories-over-Australia/Nineties/In-India')
os.makedirs('Victories-over-Australia/Twenty-first-century/In-Australia')
os.makedirs('Victories-over-Australia/Twenty-first-century/In-India')
os.removedirs('Wins-over-Zimbabwe/In-Zimbabwe')
os.removedirs('Wins-over-Zimbabwe/In-India')
os.rmdir('Triumphs-over-New-Zealand')
os.rename('Trent-Bridge-2007-K20.txt', 'Zaheer-Khan-Man-of-the-Match.txt')

print()
os.stat('Kolkata-2001-K10.txt')
print(os.stat('Kolkata-2001-K10.txt'))
print(os.stat('Kolkata-2001-K10.txt').st_size)
print(os.stat('Kolkata-2001-K10.txt').st_mtime)
modification_time = os.stat('Kolkata-2001-K10.txt').st_mtime
## The below line is possible because I have included the "from datetime import datetime" at the beginning of this program
print(datetime.fromtimestamp(modification_time))

## Entire directory tree
os.walk('/Python.scripts/Memorable-Tests')

for directory_path, directory_names, list_of_files in os.walk('/Python-scripts/Memorable-Tests'):
  print('Current path: ', directory_path)
  print('Directories: ', directory_names)
  print('List of files: ', list_of_files)
  print()

## Miscellaneous ways of checking and displaying file listings and directories
print(os.path.basename('/Python-scripts/Memorable-Tests/Kolkata-2001-K10.txt'))
print(os.path.dirname('/Python-scripts/Memorable-Tests/Kolkata-2001-K10.txt'))
print(os.path.split('/Python-scripts/Memorable-Tests/Kolkata-2001-K10.txt'))
print(os.path.exists('/Python-scripts/Memorable-Tests/Kolkata-2001-K10.txt'))
print(os.path.isdir('/Python-scripts/Memorable-Tests/Kolkata-2001-K10.txt'))
print(os.path.isfile('/Python-scripts/Memorable-Tests/Kolkata-2001-K10.txt'))
print(os.path.splitext('/Python-scripts/Memorable-Tests/Kolkata-2001-K10.txt'))

##print(dir(os.path))

Before the script execution

ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts/Memorable-Tests >
ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts/Memorable-Tests > ls -altr
total 12
-rw-r--r--. 1 root root    0 Feb 27 07:02 PortofSpain-1976-K02.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Chennai-2008-K15.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Oval-1971-K01.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Madras-1998-K08.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Lords-2014-K17.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Delhi-1999-K09.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Mumbai-2016-K19.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Kanpur-1996-K07.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Adelaide-2003-K12.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Mohali-2010-K16.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Lords-1986-K04.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Kolkata-2005-K13.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Melbourne-1977-K03.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Calcutta-1993-K05.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Perth-2008-K14.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Headingley-2002-K11.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Vishakapatnam-2016-K18.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Ahmedabad-1996-K06.txt
-rw-r--r--. 1 root root  629 Feb 28 03:44 Kolkata-2001-K10.txt
-rw-r--r--. 1 root root    0 Feb 28 03:45 Trent-Bridge-2007-K20.txt
drwxr-xr-x. 4 root root   41 Feb 28 03:59 Wins-over-Zimbabwe
drwxr-xr-x. 2 root root    6 Feb 28 04:00 Triumphs-over-New-Zealand
drwxr-xr-x. 4 root root 4096 Feb 28 04:00 .
drwxr-xr-x. 3 root root 4096 Feb 28 04:00 ..
ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts/Memorable-Tests >
ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts/Memorable-Tests > ls -altr Triumphs-over-New-Zealand/
total 4
drwxr-xr-x. 4 root root 4096 Feb 28 04:00 ..
drwxr-xr-x. 2 root root    6 Feb 28 04:00 .
ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts/Memorable-Tests >
ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts/Memorable-Tests > ls -altr Wins-over-Zimbabwe/
total 4
drwxr-xr-x. 2 root root    6 Feb 28 03:59 In-India
drwxr-xr-x. 2 root root    6 Feb 28 03:59 In-Zimbabwe
drwxr-xr-x. 4 root root   41 Feb 28 03:59 .
drwxr-xr-x. 4 root root 4096 Feb 28 04:00 ..
ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts/Memorable-Tests >
ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts/Memorable-Tests >


Execution

/Python-scripts
/Python-scripts/Memorable-Tests
['Vishakapatnam-2016-K18.txt', 'Madras-1998-K08.txt', 'Chennai-2008-K15.txt', 'Oval-1971-K01.txt', 'Kanpur-1996-K07.txt', 'Mohali-2010-K16.txt', 'Mumbai-2016-K19.txt', 'Kolkata-2005-K13.txt', 'Melbourne-1977-K03.txt', 'Lords-1986-K04.txt', 'PortofSpain-1976-K02.txt', 'Lords-2014-K17.txt', 'Headingley-2002-K11.txt', 'Ahmedabad-1996-K06.txt', 'Perth-2008-K14.txt', 'Adelaide-2003-K12.txt', 'Calcutta-1993-K05.txt', 'Delhi-1999-K09.txt', 'Kolkata-2001-K10.txt', 'Trent-Bridge-2007-K20.txt', 'Wins-over-Zimbabwe', 'Triumphs-over-New-Zealand']

os.stat_result(st_mode=33188, st_ino=5039151, st_dev=51714, st_nlink=1, st_uid=0, st_gid=0, st_size=629, st_atime=1488253486, st_mtime=1488253477, st_ctime=1488253477)
629
1488253477.7849207
2017-02-28 03:44:37.784921
Current path:  /Python-scripts/Memorable-Tests
Directories:  ['Victories-over-Australia']
List of files:  ['Vishakapatnam-2016-K18.txt', 'Madras-1998-K08.txt', 'Chennai-2008-K15.txt', 'Oval-1971-K01.txt', 'Kanpur-1996-K07.txt', 'Mohali-2010-K16.txt', 'Mumbai-2016-K19.txt', 'Kolkata-2005-K13.txt', 'Melbourne-1977-K03.txt', 'Lords-1986-K04.txt', 'PortofSpain-1976-K02.txt', 'Lords-2014-K17.txt', 'Headingley-2002-K11.txt', 'Ahmedabad-1996-K06.txt', 'Perth-2008-K14.txt', 'Adelaide-2003-K12.txt', 'Calcutta-1993-K05.txt', 'Delhi-1999-K09.txt', 'Kolkata-2001-K10.txt', 'Zaheer-Khan-Man-of-the-Match.txt']

Current path:  /Python-scripts/Memorable-Tests/Victories-over-Australia
Directories:  ['Eighties', 'Nineties', 'Twenty-first-century']
List of files:  []

Current path:  /Python-scripts/Memorable-Tests/Victories-over-Australia/Eighties
Directories:  ['In-Australia', 'In-India']
List of files:  []

Current path:  /Python-scripts/Memorable-Tests/Victories-over-Australia/Eighties/In-Australia
Directories:  []
List of files:  []

Current path:  /Python-scripts/Memorable-Tests/Victories-over-Australia/Eighties/In-India
Directories:  []
List of files:  []

Current path:  /Python-scripts/Memorable-Tests/Victories-over-Australia/Nineties
Directories:  ['In-Australia', 'In-India']
List of files:  []

Current path:  /Python-scripts/Memorable-Tests/Victories-over-Australia/Nineties/In-Australia
Directories:  []
List of files:  []

Current path:  /Python-scripts/Memorable-Tests/Victories-over-Australia/Nineties/In-India
Directories:  []
List of files:  []

Current path:  /Python-scripts/Memorable-Tests/Victories-over-Australia/Twenty-first-century
Directories:  ['In-Australia', 'In-India']
List of files:  []

Current path:  /Python-scripts/Memorable-Tests/Victories-over-Australia/Twenty-first-century/In-Australia
Directories:  []
List of files:  []

Current path:  /Python-scripts/Memorable-Tests/Victories-over-Australia/Twenty-first-century/In-India
Directories:  []
List of files:  []

Kolkata-2001-K10.txt
/Python-scripts/Memorable-Tests
('/Python-scripts/Memorable-Tests', 'Kolkata-2001-K10.txt')
True
False
True
('/Python-scripts/Memorable-Tests/Kolkata-2001-K10', '.txt')



After the execution of the script
ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts/Memorable-Tests >
ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts/Memorable-Tests > ls -altr
total 12
-rw-r--r--. 1 root root    0 Feb 27 07:02 PortofSpain-1976-K02.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Chennai-2008-K15.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Oval-1971-K01.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Madras-1998-K08.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Lords-2014-K17.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Delhi-1999-K09.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Mumbai-2016-K19.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Kanpur-1996-K07.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Adelaide-2003-K12.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Mohali-2010-K16.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Lords-1986-K04.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Kolkata-2005-K13.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Melbourne-1977-K03.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Calcutta-1993-K05.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Perth-2008-K14.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Headingley-2002-K11.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Vishakapatnam-2016-K18.txt
-rw-r--r--. 1 root root    0 Feb 27 07:02 Ahmedabad-1996-K06.txt
-rw-r--r--. 1 root root  629 Feb 28 03:44 Kolkata-2001-K10.txt
-rw-r--r--. 1 root root    0 Feb 28 03:45 Zaheer-Khan-Man-of-the-Match.txt
drwxr-xr-x. 3 root root 4096 Feb 28 04:09 ..
drwxr-xr-x. 5 root root   66 Feb 28 04:09 Victories-over-Australia
drwxr-xr-x. 3 root root 4096 Feb 28 04:09 .
ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts/Memorable-Tests >
ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts/Memorable-Tests > cd Victories-over-Australia/
ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts/Memorable-Tests/Victories-over-Australia >
ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts/Memorable-Tests/Victories-over-Australia > ls -altr
total 4
drwxr-xr-x. 4 root root   42 Feb 28 04:09 Twenty-first-century
drwxr-xr-x. 4 root root   42 Feb 28 04:09 Nineties
drwxr-xr-x. 4 root root   42 Feb 28 04:09 Eighties
drwxr-xr-x. 3 root root 4096 Feb 28 04:09 ..
drwxr-xr-x. 5 root root   66 Feb 28 04:09 .
ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts/Memorable-Tests/Victories-over-Australia >
ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts/Memorable-Tests/Victories-over-Australia >



The directory "Victories-over-Australia" got created as well as some directories below it.

The file "Trent-Bridge-2007-K20.txt" got renamed to "Zaheer-Khan-Man-of-the-Match.txt" .

Notice that the two sub-directories inside "Wins-over-Zimbabwe" i.e. "In-India" and "In-Zimbabwe" are gone.  And the parent directory "Wins-over-Zimbabwe" is gone as well.

Also notice that the directory "Triumphs-over-New-Zealand" is gone.








Reading from a file: various methods

Script

#!/usr/local/bin/python3.5

import os
import time

adelaide = open('/Python-scripts/Memorable-Tests/Adelaide-2003-K12.txt', 'r')
print()
print("Filename: ", adelaide.name)
print("Mode of opening the file: ", adelaide.mode)
print()
print("----------------------------------------------------------------------------------")
adelaide.close()

with open('/Python-scripts/Memorable-Tests/Adelaide-2003-K12.txt', 'r') as adelaide:
  adelaide_contents = adelaide.read()
  print(adelaide_contents)

print("----------------------------------------------------------------------------------")

with open('/Python-scripts/Memorable-Tests/Adelaide-2003-K12.txt', 'r') as adelaide:
  adelaide_contents = adelaide.readline()
  print(adelaide_contents)
  print("\n\n----------------------------------------------------------------------------\n\n")
print("The first 300 characters in the file")
print("====================================")
adelaide_contents = adelaide.read(300)
print(adelaide_contents)
print()
print("The next set of 300 characters in the file")
print("==========================================")
adelaide_contents = adelaide.read(300)
print(adelaide_contents)
print("\n\n----------------------------------------------------------------------------\n\n")

with open('/Python-scripts/Memorable-Tests/Adelaide-2003-K12.txt', 'r') as adelaide:
  for line_by_line in adelaide:
print(line_by_line, end='')

print()
print("----------------------------------------------------------------------------------")
with open('/Python-scripts/Memorable-Tests/Adelaide-2003-K12.txt', 'r') as adelaide:
  size_to_read = 600
  adelaide_contents = adelaide.read(size_to_read)
  while len(adelaide_contents) > 0:
print()
print("Reading 600 characters at a time.......")
print("Pausing for 3 seconds........")
time.sleep(3)
print(adelaide_contents, end='')
adelaide_contents = adelaide.read(size_to_read)

print("----------------------------------------------------------------------------------")
print()

with open('/Python-scripts/Memorable-Tests/Adelaide-2003-K12.txt', 'r') as adelaide:
  size_to_read = 250
  adelaide_contents = adelaide.read(size_to_read)
  print("Understanding how the \"TELL\" option works.....")
  while len(adelaide_contents) > 0:
  print("We are currently at the position number: ", adelaide.tell())
  time.sleep(2)
  adelaide_contents = adelaide.read(size_to_read)


Background

ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts/Memorable-Tests >
ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts/Memorable-Tests > cat Adelaide-2003-K12.txt
Border-Gavaskar Trophy - 2nd Test
Australia v India
India won by 4 wickets
Test no. 1673 | 2003/04 season
Played at Adelaide Oval
12,13,14,15,16 December 2003 (5-day match)
  Australia 1st innings R M B 4s 6s SR
JL Langer c Sehwag b Kumble 58 116 72 72
ML Hayden c †Patel b Pathan 12 22 15 20
RT Ponting c Dravid b Kumble 242 508 352 31
DR Martyn c Laxman b Nehra 30 50 39 6
SR Waugh* b Nehra 30 69 53 5 0
SM Katich c Sehwag b Agarkar 75 136 109 9
AC Gilchrist† c Sehwag b Agarkar 29 34 24 4
AJ Bichel c Chopra b Kumble 19 51 45 2
JN Gillespie not out 48 74 53 6 0
BA Williams b Kumble 0 2 3 0 0
SCG MacGill lbw b Kumble 0 1 1 0 0
Extras (lb 8, w 1, nb 4) 13
  Total (all out; 127 overs; 537 mins) 556 (4.37 runs per over)

  India 1st innings R M B 4s 6s SR
A Chopra c & b Bichel 27 52 44 3 0
V Sehwag c Hayden b Bichel 47 69 41 6
R Dravid c Bichel b Gillespie 233 594 446 23
SR Tendulkar c †Gilchrist b Bichel 1 15 6 0
SC Ganguly* run out (Williams/MacGill) 2 10 7
VVS Laxman c †Gilchrist b Bichel 148 356 282 18
PA Patel† c Ponting b Katich 31 65 52 6
AB Agarkar c MacGill b Katich 11 31 30 1
A Kumble lbw b MacGill 12 53 44 1 0
IK Pathan c & b MacGill 1 24 13 0 0
A Nehra not out 0 18 8 0 0 0.00
Extras (b 4, lb 2, w 2, nb 2) 10
  Total (all out; 161.5 overs) 523 (3.23 runs per over)

  Australia 2nd innings R M B 4s 6s SR
JL Langer lbw b Agarkar 10 10 8 1 0
ML Hayden c Sehwag b Nehra 17 56 32 0
RT Ponting c Chopra b Agarkar 0 19 17 0
DR Martyn c Dravid b Tendulkar 38 111 76 4
SR Waugh* c Dravid b Tendulkar 42 86 65 8
SM Katich c Nehra b Agarkar 31 86 58 1
AC Gilchrist† b Kumble 43 59 45 4 2
AJ Bichel b Agarkar 1 5 6 0 0
JN Gillespie c †Patel b Agarkar 3 21 19 0
BA Williams not out 4 18 9 0 0
SCG MacGill b Agarkar 1 6 4 0 0
Extras (b 2, lb 2, w 1, nb 1) 6
  Total (all out; 56.2 overs; 248 mins) 196 (3.47 runs per over)

  India 2nd innings (target: 230 runs) R M B 4s
A Chopra lbw b Gillespie 20 64 54 2 0
V Sehwag st †Gilchrist b MacGill 47 120 81 7
R Dravid not out 72 241 170 7 0
SR Tendulkar lbw b MacGill 37 79 59 5 0
SC Ganguly* c Katich b Bichel 12 41 22 1
VVS Laxman c Bichel b Katich 32 44 34 6
PA Patel† b Katich 3 15 16 0 0
AB Agarkar not out 0 2 0 0 0 -
Extras (b 3, lb 6, w 1) 10
  Total (6 wickets; 72.4 overs; 306 mins) 233 (3.20 runs per over)
Did not batA Kumble, IK Pathan, A Nehra
ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts/Memorable-Tests >
ip-172-31-24-12.us-west-2.compute.internal: /Python-scripts/Memorable-Tests >


Execution

Filename:  /Python-scripts/Memorable-Tests/Adelaide-2003-K12.txt
Mode of opening the file:  r

----------------------------------------------------------------------------------
Border-Gavaskar Trophy - 2nd Test
Australia v India
India won by 4 wickets
Test no. 1673 | 2003/04 season
Played at Adelaide Oval
12,13,14,15,16 December 2003 (5-day match)
  Australia 1st innings R M B 4s 6s SR
JL Langer c Sehwag b Kumble 58 116 72 72
ML Hayden c †Patel b Pathan 12 22 15 20
RT Ponting c Dravid b Kumble 242 508 352 31
DR Martyn c Laxman b Nehra 30 50 39 6
SR Waugh* b Nehra 30 69 53 5 0
SM Katich c Sehwag b Agarkar 75 136 109 9
AC Gilchrist† c Sehwag b Agarkar 29 34 24 4
AJ Bichel c Chopra b Kumble 19 51 45 2
JN Gillespie not out 48 74 53 6 0
BA Williams b Kumble 0 2 3 0 0
SCG MacGill lbw b Kumble 0 1 1 0 0
Extras (lb 8, w 1, nb 4) 13
  Total (all out; 127 overs; 537 mins) 556 (4.37 runs per over)

  India 1st innings R M B 4s 6s SR
A Chopra c & b Bichel 27 52 44 3 0
V Sehwag c Hayden b Bichel 47 69 41 6
R Dravid c Bichel b Gillespie 233 594 446 23
SR Tendulkar c †Gilchrist b Bichel 1 15 6 0
SC Ganguly* run out (Williams/MacGill) 2 10 7
VVS Laxman c †Gilchrist b Bichel 148 356 282 18
PA Patel† c Ponting b Katich 31 65 52 6
AB Agarkar c MacGill b Katich 11 31 30 1
A Kumble lbw b MacGill 12 53 44 1 0
IK Pathan c & b MacGill 1 24 13 0 0
A Nehra not out 0 18 8 0 0 0.00
Extras (b 4, lb 2, w 2, nb 2) 10
  Total (all out; 161.5 overs) 523 (3.23 runs per over)

  Australia 2nd innings R M B 4s 6s SR
JL Langer lbw b Agarkar 10 10 8 1 0
ML Hayden c Sehwag b Nehra 17 56 32 0
RT Ponting c Chopra b Agarkar 0 19 17 0
DR Martyn c Dravid b Tendulkar 38 111 76 4
SR Waugh* c Dravid b Tendulkar 42 86 65 8
SM Katich c Nehra b Agarkar 31 86 58 1
AC Gilchrist† b Kumble 43 59 45 4 2
AJ Bichel b Agarkar 1 5 6 0 0
JN Gillespie c †Patel b Agarkar 3 21 19 0
BA Williams not out 4 18 9 0 0
SCG MacGill b Agarkar 1 6 4 0 0
Extras (b 2, lb 2, w 1, nb 1) 6
  Total (all out; 56.2 overs; 248 mins) 196 (3.47 runs per over)

  India 2nd innings (target: 230 runs) R M B 4s
A Chopra lbw b Gillespie 20 64 54 2 0
V Sehwag st †Gilchrist b MacGill 47 120 81 7
R Dravid not out 72 241 170 7 0
SR Tendulkar lbw b MacGill 37 79 59 5 0
SC Ganguly* c Katich b Bichel 12 41 22 1
VVS Laxman c Bichel b Katich 32 44 34 6
PA Patel† b Katich 3 15 16 0 0
AB Agarkar not out 0 2 0 0 0 -
Extras (b 3, lb 6, w 1) 10
  Total (6 wickets; 72.4 overs; 306 mins) 233 (3.20 runs per over)
Did not batA Kumble, IK Pathan, A Nehra

----------------------------------------------------------------------------------
Border-Gavaskar Trophy - 2nd Test



----------------------------------------------------------------------------


The first 300 characters in the file
====================================
Australia v India
India won by 4 wickets
Test no. 1673 | 2003/04 season
Played at Adelaide Oval
12,13,14,15,16 December 2003 (5-day match)
  Australia 1st innings R M B 4s 6s SR
JL Langer c Sehwag b Kumble 58 116 72 72
ML Hayden c †Patel b Pathan 12 22 15 20
RT Ponting c Dravid b Kumble 242 508 3

The next set of 300 characters in the file
==========================================
52 31
DR Martyn c Laxman b Nehra 30 50 39 6
SR Waugh* b Nehra 30 69 53 5 0
SM Katich c Sehwag b Agarkar 75 136 109 9
AC Gilchrist† c Sehwag b Agarkar 29 34 24 4
AJ Bichel c Chopra b Kumble 19 51 45 2
JN Gillespie not out 48 74 53 6 0
BA Williams b Kumble 0 2 3 0 0
SCG MacGill lbw b Kumble


----------------------------------------------------------------------------


Border-Gavaskar Trophy - 2nd Test
Australia v India
India won by 4 wickets
Test no. 1673 | 2003/04 season
Played at Adelaide Oval
12,13,14,15,16 December 2003 (5-day match)
  Australia 1st innings R M B 4s 6s SR
JL Langer c Sehwag b Kumble 58 116 72 72
ML Hayden c †Patel b Pathan 12 22 15 20
RT Ponting c Dravid b Kumble 242 508 352 31
DR Martyn c Laxman b Nehra 30 50 39 6
SR Waugh* b Nehra 30 69 53 5 0
SM Katich c Sehwag b Agarkar 75 136 109 9
AC Gilchrist† c Sehwag b Agarkar 29 34 24 4
AJ Bichel c Chopra b Kumble 19 51 45 2
JN Gillespie not out 48 74 53 6 0
BA Williams b Kumble 0 2 3 0 0
SCG MacGill lbw b Kumble 0 1 1 0 0
Extras (lb 8, w 1, nb 4) 13
  Total (all out; 127 overs; 537 mins) 556 (4.37 runs per over)

  India 1st innings R M B 4s 6s SR
A Chopra c & b Bichel 27 52 44 3 0
V Sehwag c Hayden b Bichel 47 69 41 6
R Dravid c Bichel b Gillespie 233 594 446 23
SR Tendulkar c †Gilchrist b Bichel 1 15 6 0
SC Ganguly* run out (Williams/MacGill) 2 10 7
VVS Laxman c †Gilchrist b Bichel 148 356 282 18
PA Patel† c Ponting b Katich 31 65 52 6
AB Agarkar c MacGill b Katich 11 31 30 1
A Kumble lbw b MacGill 12 53 44 1 0
IK Pathan c & b MacGill 1 24 13 0 0
A Nehra not out 0 18 8 0 0 0.00
Extras (b 4, lb 2, w 2, nb 2) 10
  Total (all out; 161.5 overs) 523 (3.23 runs per over)

  Australia 2nd innings R M B 4s 6s SR
JL Langer lbw b Agarkar 10 10 8 1 0
ML Hayden c Sehwag b Nehra 17 56 32 0
RT Ponting c Chopra b Agarkar 0 19 17 0
DR Martyn c Dravid b Tendulkar 38 111 76 4
SR Waugh* c Dravid b Tendulkar 42 86 65 8
SM Katich c Nehra b Agarkar 31 86 58 1
AC Gilchrist† b Kumble 43 59 45 4 2
AJ Bichel b Agarkar 1 5 6 0 0
JN Gillespie c †Patel b Agarkar 3 21 19 0
BA Williams not out 4 18 9 0 0
SCG MacGill b Agarkar 1 6 4 0 0
Extras (b 2, lb 2, w 1, nb 1) 6
  Total (all out; 56.2 overs; 248 mins) 196 (3.47 runs per over)

  India 2nd innings (target: 230 runs) R M B 4s
A Chopra lbw b Gillespie 20 64 54 2 0
V Sehwag st †Gilchrist b MacGill 47 120 81 7
R Dravid not out 72 241 170 7 0
SR Tendulkar lbw b MacGill 37 79 59 5 0
SC Ganguly* c Katich b Bichel 12 41 22 1
VVS Laxman c Bichel b Katich 32 44 34 6
PA Patel† b Katich 3 15 16 0 0
AB Agarkar not out 0 2 0 0 0 -
Extras (b 3, lb 6, w 1) 10
  Total (6 wickets; 72.4 overs; 306 mins) 233 (3.20 runs per over)
Did not batA Kumble, IK Pathan, A Nehra

----------------------------------------------------------------------------------

Reading 600 characters at a time.......
Pausing for 3 seconds........
Border-Gavaskar Trophy - 2nd Test
Australia v India
India won by 4 wickets
Test no. 1673 | 2003/04 season
Played at Adelaide Oval
12,13,14,15,16 December 2003 (5-day match)
  Australia 1st innings R M B 4s 6s SR
JL Langer c Sehwag b Kumble 58 116 72 72
ML Hayden c †Patel b Pathan 12 22 15 20
RT Ponting c Dravid b Kumble 242 508 352 31
DR Martyn c Laxman b Nehra 30 50 39 6
SR Waugh* b Nehra 30 69 53 5 0
SM Katich c Sehwag b Agarkar 75 136 109 9
AC Gilchrist† c Sehwag b Agarkar 29 34 24 4
AJ Bichel c Chopra b Kumble 19 51 45 2
JN Gillespie not out 48 74 53 6 0
BA Williams b Kumble 0
Reading 600 characters at a time.......
Pausing for 3 seconds........
2 3 0 0
SCG MacGill lbw b Kumble 0 1 1 0 0
Extras (lb 8, w 1, nb 4) 13
  Total (all out; 127 overs; 537 mins) 556 (4.37 runs per over)

  India 1st innings R M B 4s 6s SR
A Chopra c & b Bichel 27 52 44 3 0
V Sehwag c Hayden b Bichel 47 69 41 6
R Dravid c Bichel b Gillespie 233 594 446 23
SR Tendulkar c †Gilchrist b Bichel 1 15 6 0
SC Ganguly* run out (Williams/MacGill) 2 10 7
VVS Laxman c †Gilchrist b Bichel 148 356 282 18
PA Patel† c Ponting b Katich 31 65 52 6
AB Agarkar c MacGill b Katich 11 31 30 1
A Kumble lbw b MacGill 12 53 44 1 0
IK Pathan c & b MacGill 1 24 13 0 0
A
Reading 600 characters at a time.......
Pausing for 3 seconds........
Nehra not out 0 18 8 0 0 0.00
Extras (b 4, lb 2, w 2, nb 2) 10
  Total (all out; 161.5 overs) 523 (3.23 runs per over)

  Australia 2nd innings R M B 4s 6s SR
JL Langer lbw b Agarkar 10 10 8 1 0
ML Hayden c Sehwag b Nehra 17 56 32 0
RT Ponting c Chopra b Agarkar 0 19 17 0
DR Martyn c Dravid b Tendulkar 38 111 76 4
SR Waugh* c Dravid b Tendulkar 42 86 65 8
SM Katich c Nehra b Agarkar 31 86 58 1
AC Gilchrist† b Kumble 43 59 45 4 2
AJ Bichel b Agarkar 1 5 6 0 0
JN Gillespie c †Patel b Agarkar 3 21 19 0
BA Williams not out 4 18 9 0 0
SCG MacGill b Agarkar 1 6 4 0 0
Extras (b 2,
Reading 600 characters at a time.......
Pausing for 3 seconds........
lb 2, w 1, nb 1) 6
  Total (all out; 56.2 overs; 248 mins) 196 (3.47 runs per over)

  India 2nd innings (target: 230 runs) R M B 4s
A Chopra lbw b Gillespie 20 64 54 2 0
V Sehwag st †Gilchrist b MacGill 47 120 81 7
R Dravid not out 72 241 170 7 0
SR Tendulkar lbw b MacGill 37 79 59 5 0
SC Ganguly* c Katich b Bichel 12 41 22 1
VVS Laxman c Bichel b Katich 32 44 34 6
PA Patel† b Katich 3 15 16 0 0
AB Agarkar not out 0 2 0 0 0 -
Extras (b 3, lb 6, w 1) 10
  Total (6 wickets; 72.4 overs; 306 mins) 233 (3.20 runs per over)
Did not batA Kumble, IK Pathan, A Nehra
----------------------------------------------------------------------------------

Understanding how the "TELL" option works.....
We are currently at the position number:  250
We are currently at the position number:  504
We are currently at the position number:  754
We are currently at the position number:  1006
We are currently at the position number:  1260
We are currently at the position number:  1510
We are currently at the position number:  1764
We are currently at the position number:  2016
We are currently at the position number:  2268
We are currently at the position number:  2403