File: demo_runcmd

package info (click to toggle)
runawk 1.6.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 712 kB
  • sloc: awk: 1,127; ansic: 736; sh: 420; makefile: 103
file content (26 lines) | stat: -rwxr-xr-x 427 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/env runawk

#use "runcmd.awk"

# Demo foir runcmd.awk module

BEGIN {
	fn1 = "file name.txt"
	fn2 = "~file&name'foobar'.txt"

	xruncmd1("touch", "", fn1)
	xruncmd1("echo", "foobar >", fn2)

	xruncmd1("ls", "-1", fn1)
	xruncmd1("ls", "", fn2)

	ret = runcmd1("grep", "baz", fn2)
	assert(1 == ret, "runcmd failed, exit status: " ret)

	xruncmd1("rm", "-f", fn1)
	xruncmd1("rm", "", fn2)

	print "succeeded"

	exit 0
}