<p>What would be the best way to do an <code>scp</code> or <code>sftp</code> copy in a Unix environment using C?</p>
<p>I'm interested in knowing the best library to use and an example if at all possible. I'm working on a <a href="https://en.wikipedia.org/wiki/Solaris_%28operating_system%29" rel="nofollow noreferrer">Solaris</a> server with the <em><a href="https://en.wikipedia.org/wiki/Sun_Microsystems" rel="nofollow noreferrer">Sun</a> tools</em> installed.</p>

In the past, I've simply called a shell script that contained the file transfer code.
```
```
int transferFile()
{
  // Declare the transfer command
  char transferCommand[50] = "/home/tyler/transferFile.shl";
  // Execute the command
  return system(transferCommand);
}
```
```
This will return 1 if the transfer command returns successfully.