#!/usr/bin/env python
# encoding: utf-8

from __future__ import with_statement
from fabric.api import cd,run,env,settings,hide
import socket
from StringIO import StringIO

hostname = 'home.blackh4t.org'
ip = socket.gethostbyname(hostname)
username = 'root'
password = ''
port = '29441'
env.hosts=[username + '@' + ip + ':'+ port,] #ssh要用到的参数
env.password = password

def down(url):
	strio = StringIO()
	print "[***] remote ssh simple http file server ..."
	with settings(
        hide('warnings', 'running','output'), #stdout , stderr 
        warn_only=True
    ):
		with cd('/tmp'):
			wget_rs = run('wget -O --no-check-certificate ' + url)  #远程操作用run
			# Saving to: `packer_0.8.1_darwin_amd64.zip.6'
			print type(wget_rs)
			print wget_rs

			
			#print 'http://' + ip + '/' + save_name
			run('python -m SimpleHTTPServer 8888' , stdout = strio)

'''
!!!first use!!!
pip install fabric
usage:
	fab -f remote_ssh_down down:url=xxxx
sh -c "echo "
- bash file content -
===============================================

'''

#!/usr/bin/env python
# encoding: utf-8

from __future__ import with_statement
from fabric.api import cd,run,env,settings,hide
import socket
from StringIO import StringIO

hostname = 'home.blackh4t.org'
ip = socket.gethostbyname(hostname)
username = 'root'
password = ''
port = '29441'
env.hosts=[username + '@' + ip + ':'+ port,] #ssh要用到的参数
env.password = password

def down(url):
	strio = StringIO()
	print "[***] remote ssh simple http file server ..."
	with settings(
        hide('warnings', 'running','output'), #stdout , stderr 
        warn_only=True
    ):
		with cd('/tmp'):
			wget_rs = run('wget -O --no-check-certificate ' + url)  #远程操作用run
			# Saving to: `packer_0.8.1_darwin_amd64.zip.6'
			print type(wget_rs)
			print wget_rs

			
			#print 'http://' + ip + '/' + save_name
			run('python -m SimpleHTTPServer 8888' , stdout = strio)

'''
!!!first use!!!
pip install fabric
usage:
	fab -f remote_ssh_down down:url=xxxx
sh -c "echo "
- bash file content -
===============================================

'''

#!/usr/bin/env python # encoding: utf-8 #ssh要用到的参数 #stdout , stderr #远程操作用run # Saving to: `packer_0.8.1_darwin_amd64.zip.6' #print 'http://' + ip + '/' + save_name !!!first use!!! pip install fabric usage: 	fab -f remote_ssh_down down:url=xxxx sh -c "echo " - bash file content - ===============================================