On 23/04/13 18:24, Graham Leggett wrote:
> Hi all,
> 
> According to the FAQ entry at http://augeas.net/faq.html, the augtool command 
> can be used to manipulate the tree from a script, but there doesn't seem to 
> be a link to any documentation that would describe how to do this with 
> working examples.
> 
> The closest I've found is the url 
> http://stackoverflow.com/questions/9118123/using-sed-to-change-etc-fstab 
> however trying to follow it's example I get augtool running silently with no 
> error, but not doing anything to the file /etc/fstab:
> 
> augtool set '/files/etc/fstab/[file=/home/monica/foo]/file' /home/monica/foo
> augtool set '/files/etc/fstab/[file=/home/monica/foo]/spec' 
> /dev/vg001/home-monica-foo
> augtool save

You're missing a "*" here which helps you find any node under fstab with
the given "file" subnode, plus the file values should be quoted:

set /files/etc/fstab/*[file="/home/monica/foo"]/spec
/dev/vg001/home-monica-foo

> Does anyone know how to get some kind of diagnostics or debugging out of 
> augtool, to confirm that it is actually doing anything?

I'd suggest doing two things to narrow this down in future:

1. use "print" and "match" commands to check the path expressions you're
using find the right nodes, e.g.

augtool> print /files/etc/fstab/*[file="/home"]
/files/etc/fstab/3
/files/etc/fstab/3/spec =
"/dev/mapper/luks-10f63ee4-8296-434e-8de1-cde932e8a2e1"
etc...

whereas an incorrect path will simply return no output / matching nodes.

2. use "print" and "get" before and after setting values to see if it
worked:

augtool> get /files/etc/fstab/*[file="/home"]/spec
/files/etc/fstab/*[file="/home"]/spec =
/dev/mapper/luks-10f63ee4-8296-434e-8de1-cde932e8a2e1
augtool> set /files/etc/fstab/*[file="/home"]/spec /dev/sda3
augtool> get /files/etc/fstab/*[file="/home"]/spec
/files/etc/fstab/*[file="/home"]/spec = /dev/sda3

Regards,

-- 
Dominic Cleal
Red Hat Engineering

_______________________________________________
augeas-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/augeas-devel

Reply via email to