Created
February 22, 2013 05:09
-
-
Save windwiny/5010865 to your computer and use it in GitHub Desktop.
ruby program wrap. write log on before and after run ori_porg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# ruby program wrap. | |
# mv /usr/bin/aaa /usr/bin/aaa_ori | |
# cp ./pg_wrap.rb /usr/bin/aaa | |
RED="\033[0;31m" | |
GREEN="\033[0;32m" | |
BLUE="\033[0;33m" | |
WHITE="\033[00m" | |
PG=__FILE__ | |
PG_ORI=PG+'_ori' | |
LOG_F='/tmp/log' | |
ARGV2 = ARGV.map{|x| x=~/[ ']/ ? "\"#{x.gsub("\"","\\\"")}\"" : x.gsub("\"","\\\"")}.join(' ') | |
str = "#{Time.now} #{GREEN}#{PG} #{ARGV2}#{WHITE}\n" | |
print str | |
File.open(LOG_F,'ab'){ |f| f.write str } | |
system("#{PG_ORI} #{ARGV2}") | |
str = "#{Time.now} #{RED}#{PG_ORI} return => [ #{$?.exitstatus} ]#{WHITE}\n\n" | |
print str | |
File.open(LOG_F,'ab'){ |f| f.write str } | |
exit $?.exitstatus |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment