Python:
import sys
input_string = sys.argv[1]
compressed_string = ''
last_letter = ''
letter_count = 0
for letter in input_string:
if letter != last_letter:
if last_letter != '':
compressed_string += last_letter + str(letter_count)
letter_count = 0
last_letter = letter
letter_count += 1
compressed_string += last_letter + str(letter_count)
print(compressed_string)