X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=java%2Fcom%2Fredhat%2Fet%2Flibguestfs%2FGuestFS.java;h=cdc0f0947ce2c3721ead7de127ebd8643413831b;hp=d29ae54f755a76c6178836649152bcd2182ccf60;hb=ad8a256f54a6cb99f89bb444c8597a152a793dce;hpb=460d139e6a52da67a4f1947035b1978610349f78 diff --git a/java/com/redhat/et/libguestfs/GuestFS.java b/java/com/redhat/et/libguestfs/GuestFS.java index d29ae54..cdc0f09 100644 --- a/java/com/redhat/et/libguestfs/GuestFS.java +++ b/java/com/redhat/et/libguestfs/GuestFS.java @@ -1998,7 +1998,9 @@ public HashMap test0rhashtableerr () * The single parameter is an argv-style list of arguments. * The first element is the name of the program to run. * Subsequent elements are parameters. The list must be - * non-empty (ie. must contain a program name). + * non-empty (ie. must contain a program name). Note that + * the command runs directly, and is *not* invoked via the + * shell (see "g.sh"). *

* The return value is anything printed to *stdout* by the * command. @@ -2040,6 +2042,8 @@ public HashMap test0rhashtableerr () * This is the same as "g.command", but splits the result * into a list of lines. *

+ * See also: "g.sh_lines" + *

* Because of the message protocol, there is a transfer * limit of somewhere between 2MB and 4MB. To transfer * large files you should use FTP. @@ -3383,4 +3387,78 @@ public HashMap test0rhashtableerr () private native int _ntfs_3g_probe (long g, boolean rw, String device) throws LibGuestFSException; + /** + * run a command via the shell + *

+ * This call runs a command from the guest filesystem via + * the guest's "/bin/sh". + *

+ * This is like "g.command", but passes the command to: + *

+ * /bin/sh -c "command" + *

+ * Depending on the guest's shell, this usually results in + * wildcards being expanded, shell expressions being + * interpolated and so on. + *

+ * All the provisos about "g.command" apply to this call. + *

+ * @throws LibGuestFSException + */ + public String sh (String command) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("sh: handle is closed"); + return _sh (g, command); + } + private native String _sh (long g, String command) + throws LibGuestFSException; + + /** + * run a command via the shell returning lines + *

+ * This is the same as "g.sh", but splits the result into a + * list of lines. + *

+ * See also: "g.command_lines" + *

+ * @throws LibGuestFSException + */ + public String[] sh_lines (String command) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("sh_lines: handle is closed"); + return _sh_lines (g, command); + } + private native String[] _sh_lines (long g, String command) + throws LibGuestFSException; + + /** + * expand a wildcard path + *

+ * This command searches for all the pathnames matching + * "pattern" according to the wildcard expansion rules used + * by the shell. + *

+ * If no paths match, then this returns an empty list + * (note: not an error). + *

+ * It is just a wrapper around the C glob(3) function with + * flags "GLOB_MARK|GLOB_BRACE". See that manual page for + * more details. + *

+ * @throws LibGuestFSException + */ + public String[] glob_expand (String pattern) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("glob_expand: handle is closed"); + return _glob_expand (g, pattern); + } + private native String[] _glob_expand (long g, String pattern) + throws LibGuestFSException; + }