comparison bin/uptime @ 12141:bbcac610574d draft

<b_jonas> fetch /hackenv/bin/uptime https://hack.esolangs.org/get/bin/uptime
author HackEso <hackeso@esolangs.org>
date Sun, 17 Nov 2019 20:17:51 +0000
parents 2826c0c87d92
children ec79f376cd1a
comparison
equal deleted inserted replaced
12140:2826c0c87d92 12141:bbcac610574d
1 #!/usr/bin/python3 1 #!python3
2 boottime = 1245511822 2 boottime = 1245511822
3 import sys, time 3 import sys, os, time
4 helpmsg = "\nUsage:\n uptime [options]\n\nOptions:\n -p, --pretty show uptime in pretty format\n -h, --help display this help and exit\n -s, --since system up since\n -V, --version output version information and exit\n\nFor more details see uptime(1)." 4 helpmsg = "\nUsage:\n uptime [options]\n\nOptions:\n -p, --pretty show uptime in pretty format\n -h, --help display this help and exit\n -s, --since system up since\n -V, --version output version information and exit\n\nFor more details see uptime(1)."
5 opt_p, opt_s = 0, 0 5 opt_p, opt_s = 0, 0
6 for a in sys.argv[1:]: 6 for a in sys.argv[1:]:
7 if "--" == a: 7 if "--" == a:
8 break 8 break
11 if "p" == c: 11 if "p" == c:
12 opt_p = 1 12 opt_p = 1
13 elif "s" == c: 13 elif "s" == c:
14 opt_s = 1 14 opt_s = 1
15 elif "V" == c: 15 elif "V" == c:
16 print("uptime from procps-ng 3.3.15") 16 os.execl("/usr/bin/uptime", "/usr/bin/uptime", "-V")
17 print("uptime from procps-ng 2.95.1")
17 sys.exit(0) 18 sys.exit(0)
18 elif "h" == c: 19 elif "h" == c:
19 print(helpmsg, file = sys.stdout) 20 print(helpmsg, file = sys.stdout)
20 sys.exit(0) 21 sys.exit(0)
21 else: 22 else: