1 /* Example using wrappi to access a remote server and read a file. */
10 main (int argc, char *argv[])
15 /* We're going to use ssh to access the remote server. This is
16 * automatic but we need a hostname on the command line.
19 fprintf (stderr, "missing parameter: give the remote hostname\n");
26 fprintf (stderr, "could not allocate wrappi handle\n");
30 /* Set the connection method to ssh to the remote host. If you
31 * simply comment out the next two lines, then wrappi will run the
32 * commands on the local machine.
34 wrap_set_scheme (w, WRAP_SCHEME_SSH);
35 wrap_set_hostname (w, hostname);
37 /* Connect the handle. Because we didn't set any error handler,
38 * errors will be printed on stderr, so we can just exit if we get
46 /* Read a file from the remote machine. Most Un*x-like machines
47 * should have /etc/issue.
49 printf ("--- contents of /etc/issue from %s ---\n", hostname);
50 wrap_download (w, "/etc/issue", "/dev/stdout");
54 int64_t size = wrap_filesize (w, "/etc/issue");
57 printf ("size of /etc/issue = %" PRIi64 " bytes\n", size);