Пример #1
0
int scp_test(ssh_session session, ssh_scp scp)
{
    int rc;
    const char *helloworld = "Hello, world!\n";
    int length = strlen(helloworld);
    
    rc = ssh_scp_push_directory(scp, "helloworld", S_IRWXU);
    if(rc != SSH_OK)
    {
        fprintf(stderr, "Can't create remote directory: %s\n", ssh_get_error(session));
        return rc;
    }
    
    rc = ssh_scp_push_file(scp, "helloworld", length, S_IRUSR | S_IWUSR);
    if(rc != SSH_OK)
    {
        fprintf(stderr, "Can't open remote file: %s\n", ssh_get_error(session));
        return rc;
    }
    
    rc = ssh_scp_write(scp, helloworld, length);
    //ssh_option_set(my_ssh_session, SSH_OPTIONS_HOST, "localhost");
    if(rc != SSH_OK)
    {
        fprintf(stderr, "Can't write remote file: %s\n", ssh_get_error(session));
        return rc;
    }

    return SSH_OK;
}
Пример #2
0
static int lscp_push_directory(lua_State *L){
	struct scp_ud * scpud = get_scpud(L);
    const char * dirname  = luaL_checkstring(L, 2);
    const int mode  = luaL_checkinteger(L, 3);
	int r=ssh_scp_push_directory(scpud->scp,dirname,mode);
	if(r==SSH_ERROR){
		scp_error(L,scpud);
	}
	return 0;
}