<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<STYLE>
BLOCKQUOTE {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; MARGIN-LEFT: 2em
}
OL {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
UL {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
BODY {
        LINE-HEIGHT: 1.5; FONT-FAMILY: 宋体; COLOR: #000000; FONT-SIZE: 10.5pt
}
P {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
</STYLE>

<META name=GENERATOR content="MSHTML 8.00.6001.19298"></HEAD>
<BODY style="MARGIN: 10px">
<DIV>i try it in my environment,it allways throws the exception :</DIV>
<DIV 
style="TEXT-INDENT: 2em">com.redhat.et.libguestfs.LibGuestFSException: sh: /bin/sh: Exec format error</DIV>
<DIV>then i try the following programs, "Exec format error" still 
happens:</DIV>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px" dir=ltr>
  <DIV>
  <DIV 
  style="FONT-WEIGHT: bold">String cmd1 = "chkconfig --add tomcat";</DIV>
  <DIV style="FONT-WEIGHT: bold"></DIV>
  <DIV style="FONT-WEIGHT: bold">g.sh(cmd1);</DIV>
  <DIV style="FONT-WEIGHT: bold"></DIV>
  <DIV 
  style="FONT-WEIGHT: bold">String cmd2 = "/sbin/chkconfig --add tomcat";
  <DIV style="FONT-WEIGHT: bold"></DIV>
  <DIV style="FONT-WEIGHT: bold">g.sh(cmd2);</DIV>
  <DIV 
  style="FONT-WEIGHT: bold"></DIV>String[] cmd = new String[] {"/sbin/chkconfig", "--list"};</DIV>
  <DIV style="FONT-WEIGHT: bold"></DIV>
  <DIV style="FONT-WEIGHT: bold">g.command(cmd);</DIV></DIV></BLOCKQUOTE>
<DIV>but i can execute the command in system, could show me the reason, 
Thanks!</DIV>
<DIV> </DIV>
<HR style="WIDTH: 210px; HEIGHT: 1px" align=left color=#b5c4df SIZE=1>

<DIV><SPAN>周涛</SPAN></DIV>
<DIV> </DIV>
<DIV 
style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 0cm; PADDING-RIGHT: 0cm; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<DIV 
style="PADDING-BOTTOM: 8px; PADDING-LEFT: 8px; PADDING-RIGHT: 8px; BACKGROUND: #efefef; COLOR: #000000; FONT-SIZE: 12px; PADDING-TOP: 8px">
<DIV><B>From:</B> <A href="mailto:rjones@redhat.com">Richard W.M. 
Jones</A></DIV>
<DIV><B>Date:</B> 2012-08-28 00:39</DIV>
<DIV><B>To:</B> <A 
href="mailto:libguestfs@redhat.com">libguestfs@redhat.com</A></DIV>
<DIV><B>CC:</B> <A 
href="mailto:tao.zhou@neusoft.com">tao.zhou@neusoft.com</A></DIV>
<DIV><B>Subject:</B> Re: libguestfs! help!</DIV></DIV></DIV>
<DIV>
<DIV>On Sun, Aug 26, 2012 at 09:52:23PM -0400, tao zhou wrote:</DIV>
<DIV>> hello everyone!</DIV>
<DIV>></DIV>
<DIV>> first i use libguestfs API to upload a file into my linux VM , and</DIV>
<DIV>> then i want to execute some command(for example : tar xzvf XXX、</DIV>
<DIV>> chkconfig --add XXX) to config my application by java libguestfs</DIV>
<DIV>> API,what should i do? could you show me an example in java?</DIV>
<DIV>> Thanks!</DIV>
<DIV> </DIV>
<DIV>Attached is a simple example in Java.</DIV>
<DIV> </DIV>
<DIV>However to run the command it may be better to run the command using a</DIV>
<DIV>"firstboot" script.  See:</DIV>
<DIV> </DIV>
<DIV>  http://libguestfs.org/guestfs.3.html#running-commands</DIV>
<DIV>  http://libguestfs.org/virt-sysprep.1.html#firstboot-</DIV>
<DIV> </DIV>
<DIV>(Note that the ability to use firstboot scripts was only added very</DIV>
<DIV>recently to virt-sysprep).</DIV>
<DIV> </DIV>
<DIV>Rich.</DIV>
<DIV> </DIV>
<DIV>-- </DIV>
<DIV>Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones</DIV>
<DIV>New in Fedora 11: Fedora Windows cross-compiler. Compile Windows</DIV>
<DIV>programs, test, and build Windows installers. Over 70 libraries supprt'd</DIV>
<DIV>http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw</DIV>
<DIV> </DIV></DIV><p>---------------------------------------------------------------------------------------------------<br>
Confidentiality Notice: The information contained in this e-mail and any accompanying attachment(s) <br>
is intended only for the use of the intended recipient and may be confidential and/or privileged of <br>
Neusoft Corporation, its subsidiaries and/or its affiliates. If any reader of this communication is <br>
not the intended recipient, unauthorized use, forwarding, printing,  storing, disclosure or copying <br>
is strictly prohibited, and may be unlawful.If you have received this communication in error,please <br>
immediately notify the sender by return e-mail, and delete the original message and all copies from <br>
your system. Thank you. <br>
---------------------------------------------------------------------------------------------------</p></BODY></HTML>