tmate/libssh/tests/chmodtest.c
Nicolas Viennot 0f7ccda4fb Adding libssh
2013-06-10 02:50:07 -04:00

34 lines
627 B
C

#include <stdio.h>
#include <libssh/libssh.h>
#include "examples_common.h"
#include <libssh/sftp.h>
int main(void) {
ssh_session session;
sftp_session sftp;
char buffer[1024*1024];
int rc;
session = connect_ssh("localhost", NULL, 0);
if (session == NULL) {
return 1;
}
sftp=sftp_new(session);
sftp_init(sftp);
rc=sftp_rename(sftp,"/tmp/test","/tmp/test");
rc=sftp_rename(sftp,"/tmp/test","/tmp/test");
rc=sftp_chmod(sftp,"/tmp/test",0644);
if (rc < 0) {
printf("error : %s\n",ssh_get_error(sftp));
ssh_disconnect(session);
return 1;
}
ssh_disconnect(session);
return 0;
}