1

I'm trying to use augtool in shell script ex:

#!/bin/bash

augtool <<-EOF
print /augeas/load
EOF

However if I execute this script, the script will run indefinitely with no output and the CPU usage is 100% via top cmd.

the command can be run successfully using

$augtool
$print /augeas/load
/augeas/load/Webmin/excl[4] = "/*.dpkg-bak"
/augeas/load/Webmin/excl[5] = "/*.dpkg-new"
/augeas/load/Webmin/excl[6] = "/*.dpkg-old"
/augeas/load/Webmin/excl[7] = "/*.rpmsave"
/augeas/load/Webmin/excl[8] = "/*.rpmnew"
/augeas/load/Webmin/excl[9] = "/*~"
... lots of output...
augtool> quit

I'm using Ubuntu 12.04.2 and the version of augtool is 0.10.0.

My question is: how to use augtool in shell script?


[edited]

I execute the strace command and get the following error:

lstat64("/augeas/load/", 0xbfc637d8) = -1 ENOENT (No such file or directory)

and then it keeps looping and showing:

write(2, "\7", 1)                 = 1
rt_sigprocmask(SIG_BLOCK, [INT], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
read(0, "", 1)                    = 0

However if I execute this script with root, it runs successfully

3
  • 2
    FWIW I can't reproduce your problem -- when I run your first script, it completes in less than a second.
    – Flup
    Commented Jun 17, 2013 at 11:11
  • 3
    You may run your script through strace in oder to see what's happening: strace -o script.strace -f /path/to/script Commented Jun 17, 2013 at 11:45
  • 1
    Why do you use the - in front of the first EOF, in <<-EOF?
    – Bernhard
    Commented Jun 18, 2013 at 5:47

2 Answers 2

2

Like @Flup, I can't reproduce your issue.

Also note that you can actually also use augtool as an interpreter, too:

#!/usr/bin/augtool -f
print /augeas/load

Combining this with the -s (--autosave) flag if you want to make modification without explicitely calling save at the end of your script.

0

What happens if you explicitly quit from within the commands to augtool?

#!/bin/bash

augtool <<-EOF
print /augeas/load
quit
EOF

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .