2011-10-07 7 views
0

J'essaye d'insérer un nouvel élément avec xmlstarlet mais quand j'exécute la commande il suffit de lister le fichier xml que j'essaie d'insérer. Toute suggestion sera appréciée.xmlstarlet edit syntax syntax

xml ed -s /chkSys/machine/registry -t elem -n key -v "" -i /registry/key -t attr -n value -v "'C:\Program Files\Microsoft SQL Server'" -v path "HKLM\software\symantec\Symantec Endpoint Protection\AV\Exclusions\ScanningEngines" --net \\server3\e$\temp\chksys\chksys.xml 

##Old## 
<?xml version="1.0" encoding="utf-8"?> 
<chksys> 
    <machine> 
     <registry> 

     </registry> 
    </machine> 
</chksys> 

##New## 
<?xml version="1.0" encoding="utf-8"?> 
<chksys> 
    <machine> 
     <registry> 
      <key value="'C:\Program Files\Microsoft SQL Server'" path "HKLM\software\symantec\Symantec Endpoint Protection\AV\Exclusions\ScanningEngines\Directory\Admin\1075182566\DirectoryName"/> 
     </registry> 
    </machine> 
</chksys> 

Répondre

2

Votre commande est un peu loin, vous devez utiliser le chemin complet à la clé lorsque vous insérez:

xml ed --net^
    -s /chksys/machine/registry -t elem -n key -v ""^
    -i /chksys/machine/registry/key -t attr -n value^
     -v "'C:\Program Files\Microsoft SQL Server'"^
    -i /chksys/machine/registry/key -t attr -n path^
     -v "HKLM\software\symantec\Symantec Endpoint Protection\AV\Exclusions\ScanningEngines"^
    OLDFILE > NEWFILE 

Cela mettra le xml éditée dans NEWFILE, si vous voulez changer OLDFILE directement vous pouvez utiliser l'option --inplace ou -L.

xml ed --net --inplace^
    ...