def system(command):
now=time.strftime("%H:%M:%S", time.localtime())
- print "+",now
+ print "+",now,':',command
return os.system("set -x; " + command)
# checks whether a given hostname/ip responds to ping
command="ping -c 1 %s 1 %s"%(ping_timeout_option,hostname)
(status,output) = commands.getstatusoutput(command)
return status == 0
+
+# inserts a backslash before each occurence of the following chars
+# \ " ' < > & | ; ( ) $ * ~
+def backslash_shell_specials (command):
+ result=''
+ for char in command:
+ if char in "\\\"'<>&|;()$*~":
+ result +='\\'+char
+ else:
+ result +=char
+ return result
+