diff options
author | Richard Jones <rjones@trick.home.annexia.org> | 2009-06-22 07:49:50 +0100 |
---|---|---|
committer | Richard Jones <rjones@trick.home.annexia.org> | 2009-06-22 07:49:50 +0100 |
commit | 4211c7a258debd236017a19c70965bc1b3658edb (patch) | |
tree | 50372cfd72f49b84b753e2aa58c92dfc99b4586f /perl | |
parent | 57d2dfab18ad3d987d9273bb7c1f42e73e0bbcb2 (diff) | |
download | libguestfs-4211c7a258debd236017a19c70965bc1b3658edb.tar.gz libguestfs-4211c7a258debd236017a19c70965bc1b3658edb.tar.xz libguestfs-4211c7a258debd236017a19c70965bc1b3658edb.zip |
Generated code for 'sh' and 'sh-lines' commands.
Diffstat (limited to 'perl')
-rw-r--r-- | perl/Guestfs.xs | 34 | ||||
-rw-r--r-- | perl/lib/Sys/Guestfs.pm | 28 |
2 files changed, 61 insertions, 1 deletions
diff --git a/perl/Guestfs.xs b/perl/Guestfs.xs index c26faa16..8a6c4bb9 100644 --- a/perl/Guestfs.xs +++ b/perl/Guestfs.xs @@ -2549,3 +2549,37 @@ PREINIT: OUTPUT: RETVAL +SV * +sh (g, command) + guestfs_h *g; + char *command; +PREINIT: + char *output; + CODE: + output = guestfs_sh (g, command); + if (output == NULL) + croak ("sh: %s", guestfs_last_error (g)); + RETVAL = newSVpv (output, 0); + free (output); + OUTPUT: + RETVAL + +void +sh_lines (g, command) + guestfs_h *g; + char *command; +PREINIT: + char **lines; + int i, n; + PPCODE: + lines = guestfs_sh_lines (g, command); + if (lines == NULL) + croak ("sh_lines: %s", guestfs_last_error (g)); + for (n = 0; lines[n] != NULL; ++n) /**/; + EXTEND (SP, n); + for (i = 0; i < n; ++i) { + PUSHs (sv_2mortal (newSVpv (lines[i], 0))); + free (lines[i]); + } + free (lines); + diff --git a/perl/lib/Sys/Guestfs.pm b/perl/lib/Sys/Guestfs.pm index 05adfcb4..9329b769 100644 --- a/perl/lib/Sys/Guestfs.pm +++ b/perl/lib/Sys/Guestfs.pm @@ -432,7 +432,9 @@ or compatible processor architecture). 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 I<not> invoked via +the shell (see C<$h-E<gt>sh>). The return value is anything printed to I<stdout> by the command. @@ -461,6 +463,8 @@ FTP. This is the same as C<$h-E<gt>command>, but splits the result into a list of lines. +See also: C<$h-E<gt>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. @@ -1125,6 +1129,28 @@ This displays the partition table on C<device>, in the human-readable output of the L<sfdisk(8)> command. It is not intended to be parsed. +=item $output = $h->sh ($command); + +This call runs a command from the guest filesystem via the +guest's C</bin/sh>. + +This is like C<$h-E<gt>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 C<$h-E<gt>command> apply to this call. + +=item @lines = $h->sh_lines ($command); + +This is the same as C<$h-E<gt>sh>, but splits the result +into a list of lines. + +See also: C<$h-E<gt>command_lines> + =item $h->sleep ($secs); Sleep for C<secs> seconds. |