[Libguestfs] libguestfs! help!

周涛 tao.zhou at neusoft.com
Wed Aug 29 03:34:51 UTC 2012


i try it in my environment,it allways throws the exception :
com.redhat.et.libguestfs.LibGuestFSException: sh: /bin/sh: Exec format error
then i try the following programs, "Exec format error" still happens:
String cmd1 = "chkconfig --add tomcat";
g.sh(cmd1);
String cmd2 = "/sbin/chkconfig --add tomcat";
g.sh(cmd2);
String[] cmd = new String[] {"/sbin/chkconfig", "--list"};
g.command(cmd);
but i can execute the command in system, could show me the reason, Thanks!




周涛

From: Richard W.M. Jones
Date: 2012-08-28 00:39
To: libguestfs at redhat.com
CC: tao.zhou at neusoft.com
Subject: Re: libguestfs! help!
On Sun, Aug 26, 2012 at 09:52:23PM -0400, tao zhou wrote:
> hello everyone!
>
> first i use libguestfs API to upload a file into my linux VM , and
> then i want to execute some command(for example : tar xzvf XXX、
> chkconfig --add XXX) to config my application by java libguestfs
> API,what should i do? could you show me an example in java?
> Thanks!

Attached is a simple example in Java.

However to run the command it may be better to run the command using a
"firstboot" script.  See:

  http://libguestfs.org/guestfs.3.html#running-commands
  http://libguestfs.org/virt-sysprep.1.html#firstboot-

(Note that the ability to use firstboot scripts was only added very
recently to virt-sysprep).

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
New in Fedora 11: Fedora Windows cross-compiler. Compile Windows
programs, test, and build Windows installers. Over 70 libraries supprt'd
http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
---------------------------------------------------------------------------------------------------
Confidentiality Notice: The information contained in this e-mail and any accompanying attachment(s) 
is intended only for the use of the intended recipient and may be confidential and/or privileged of 
Neusoft Corporation, its subsidiaries and/or its affiliates. If any reader of this communication is 
not the intended recipient, unauthorized use, forwarding, printing,  storing, disclosure or copying 
is strictly prohibited, and may be unlawful.If you have received this communication in error,please 
immediately notify the sender by return e-mail, and delete the original message and all copies from 
your system. Thank you. 
---------------------------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20120829/8d19915f/attachment.htm>


More information about the Libguestfs mailing list