1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
#!/usr/bin/env luajit
local _ = require 'PolygLua'
I'Starting from the top.'
Help = [[
This is part of the blah blah blah...
]]
Version = '0.0 crap'
local options =
{
start = {help = 'Command to start the scanning process, for Sys V init.', value = 'blah'},
-- restart = {start},
-- ['force-reload'] = {start},
status = {help = 'Command to check the status of the scanning process, for Sys V init.',},
stop = {help = 'Command to stop the scanning process, for Sys V init.',},
JACK = {help = 'Command to start the JACK stuff, for users.',},
STOP = {help = 'Command to stop the JACK stuff, for users.',
func = function(self, options, a, args, i)
--[=[
_.killEmAll{'qsynth'}
__[[
a2j_control --stop
sleep 2
a2j_control --exit
sleep 2
]]:Do()
_.killEmAll{'alsa_in', 'alsa_out', 'zita-a2j', 'zita-j2a', 'aseqjoy', 'jack-plumbing'}
__[[
sleep 2
jack_control stop
sleep 2
jack_control exit
sleep 2
]]:Do()
_.killEmAll{'jmcore', 'qjackctl'}
-- Catia is python, and no easy way to kill it.
-- Also it keeps jackdbus alive, no matter how hard you kill it.
__'pkill -TERM -u $USER -f catia':Do()
__'sleep 2':Do()
_.killEmAll{'jackdbus', 'a2jmidid'}
]=]
end
},
}
options['restart'] = options['start']
options['force-reload'] = options['start']
print('start = ' .. options.start.value)
_.parse(arg, options, 'test_')
print('start = ' .. options.start.value)
print('stop = ' .. options.stop.value)
__[[
echo -n "This'll print forking later. "
date
sleep 2
]]:log():show():fork('echo -n "later is "; date')
print('')
local GUI = 'qjackctl'
if _.runnable'catia' then GUI = 'catia' end
local speaker = 'espeak'
if _.runnable'espeak-ng' then speaker = 'espeak-ng' end
print('' .. GUI .. ' ' .. speaker)
print('')
for i,l in ipairs(__'free -h':log():Do().lines) do
print(l)
end
print('')
for i,l in ipairs(__'uname -a\nfree -h':log():Do().lines) do
print(l)
end
print('')
__'uname -a':log():Then'free -h':show():Do()
print('')
__{'uname -a', 'free -h'}:log():show():Do()
print('')
print(__[[#!/bin/NoSuchCommand
echo "Should not print."
]]:log():show():Do().status)
print('')
__[[#!/bin/bash
echo "Hello world from bash."
]]:log():show():Do()
print('')
print(__[[#!/usr/bin/tcc -run
#include <tcclib.h>
int main()
{
printf("Hello world from C.\n");
return 0;
}
]]:log():show():Do().status)
print('')
__[[#!/usr/bin/env luajit
print('Hello ' .. "world " .. [=[from]=] .. ' Lua.')
]]:log():show():Do()
print('')
__[[#!/usr/bin/perl
print "Hello world from perl.\n";
]]:log():show():Do()
print('')
__[[#!/usr/bin/env php
<?php
print("G'day world from php.\n");
]]:log():show():Do()
print('')
-- Note no indent for Python, coz whitespace is significant.
__[[#!/usr/bin/env python3
print("Hello world from python.")
]]:log():show():Do()
print('')
__[[#!/usr/bin/ruby
puts "Hello world from ruby."
]]:log():show():Do()
print('')
print(__'true':log():show():Do().status)
print(__'false':log():show():Do().status)
print(__'exit 42':log():show():Do().status)
print(__'return 42':log():show():Do().status)
print(__'command NoSuchCommand':log():show():Do().status)
--__'qpdfview':forkOnce()
--__'qpdfview':forkOnce()
print('')
for i,a in ipairs(arg) do print('arg[' .. i .. '] = ' .. a) end
print('')
for k,a in pairs(arg) do print('arg[' .. k .. '] = ' .. a) end
__'date':log():show():Do()
-- Should get that "later" thing printed while the sleep is happening.
__'date; sleep 5; date':log():show():Do()
|