I want to use
with open(hn) as f:
if not line:
desthost = line.strip().lstrip().rstrip()
env.host_string = desthost
run('cp %s %s' %(path,path+time.strftime(r'%Y%m%d%H%M%S', time.localtime())))
run(change_conf(path, old, new))
f = fileinput.input(path,backup='.bak',inplace=True)
for line in f:
line = line.rstrip()
match = re.match(r,line)
print line.replace(old, new)
TypeError: cannot concatenate 'str' and 'NoneType' objects
run() expects string with command. It can run only programs/scripts which are on remote server - it can't run your function.
BTW: now Python first executes your function which returns
None and then
run() use this result as command to execute on server.
If you have Linux on remote server then you could use
sed command. ie.
sed "s/old_text/new_text/g" old_file > new_file
Or you have to copy your script on remote server and then run it