Skip to content

Commit

Permalink
[#6] Hack to make it work on mac os
Browse files Browse the repository at this point in the history
The problem is that script behaves differently on mac os and also  file.read does not return anything after it has read the file once.
  • Loading branch information
domoritz committed Jul 15, 2013
1 parent df6204a commit 28f5635
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions public/bin/shellshare
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import sys
import httplib2
import urllib
import os
import platform


def id_generator(size=9, chars=string.ascii_letters + string.digits):
Expand All @@ -22,11 +23,16 @@ def post(url, data):


def stream_file(path, url):
f = open(path, "r")
f = open(path, 'rb')
while True:
time.sleep(1)
data = f.read()
if not (data == ""):
data = ''
while True:
new = f.readline()
if not new:
break
data += new
if not (data == ''):
encoded_str = base64.b64encode(data)
post(url, encoded_str)

Expand All @@ -35,7 +41,14 @@ tmp = tempfile.NamedTemporaryFile()
channel = sys.argv[1] if len(sys.argv) > 1 else id_generator()
url = 'http://www.shellshare.net/%s' % channel

if platform.system() == 'Darwin':
shell_args = '-qt 0'
else:
shell_args = '-qf'

print tmp.name

print 'Sharing session in %s...' % url
thread.start_new_thread(stream_file, (tmp.name, url))
os.system('script -qf %s' % tmp.name)
os.system('script %s %s' % (shell_args, tmp.name))
print 'End of transmission.'

0 comments on commit 28f5635

Please sign in to comment.