aboutsummaryrefslogtreecommitdiff
path: root/examples/async-read-etc-hosts.js
blob: 701002ca91b031eaa611dd44e2db27aa028673a9 (plain)
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
var aug = require('../build/Release/libaugeas');


/* 
 * Create Augeas object to work with '/etc/hosts'
 * through 'hosts' lens:
 */
aug.createAugeas(
        {lens: 'hosts', incl: '/etc/hosts'},
        function(aug) {
            if (!aug.error()) {
                console.log(aug.get('/files/etc/hosts/1/ipaddr'));
                console.log(aug.match('/files/etc/hosts/*/*'));
            } else {
                console.log('Sad, but true :-(');
            }
        }
);
console.log('Waiting for Augeas ...');

/* Example output:
Waiting for Augeas ...
127.0.0.1
[ '/files/etc/hosts/1/ipaddr',
  '/files/etc/hosts/1/canonical',
  '/files/etc/hosts/1/alias[1]',
  '/files/etc/hosts/1/alias[2]',
  '/files/etc/hosts/1/alias[3]',
  '/files/etc/hosts/1/alias[4]',
  '/files/etc/hosts/2/ipaddr',
  '/files/etc/hosts/2/canonical',
  '/files/etc/hosts/3/ipaddr',
  '/files/etc/hosts/3/canonical' ]
*/