cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-library Mailing List Archives

RE: SFTP commands

From: <nagarajan.sreenivasan_at_wipro.com>
Date: Fri, 27 Jun 2008 09:25:06 +0530

On Thu, Jun 26, 2008 at 04:44:08PM +0530,
nagarajan.sreenivasan_at_wipro.com wrote:
> Hi all
>
> I am using Linux platform
>
> finally got rename working but now I have a problem with chmod
>
> scenario:
> ========
>
> I have a file with 555 permisison .
>
> I want to change it to 777 permission.
>
> but I am getting the following error
>
> * Sending quote commands
> * Attempt to set SFTP stats failed: Permission denied
> * Connection #0 to host <hostname> left intact
> * Quote command returned error
> value of res in ChmodRemoteFile is : 21(CURLE_QUOTE_ERROR (21) )

>>>>>>>>>>>>>>>>>>>>>The probably is probably just what it says:
"Permission deined". Are you sure the SFTP user has
>>>>>>>>>>>>>>>>>>>>>permission to change the mode of the given file?

Hi

Yes the sftp user has permissions and what I noticed is the permissions
are getting changed but the
Error still comes as below.

PS:with ftp the same user works fine for changing modes with out any
erros . For sftp we
Are getting errors but the permission gets changed. Do let us know what
could be the problem.

 * Sending quote commands
 * Attempt to set SFTP stats failed: Permission denied
 * Connection #0 to host <hostname> left intact
 * Quote command returned error
 value of res in ChmodRemoteFile is : 21(CURLE_QUOTE_ERROR (21) )

The fucntion is implemented as below
        ChmodRemoteFile(const pathName,const mode)
{

    struct curl_slist *headerlist=NULL;
    int errorStatus = 0;

    char *FILE_TO_CHMOD=new char[255];

    char *buf_5=new char[255];
    char *mode_to_change=new char[255];
    memset(buf_5,0,255);
    memset(mode_to_change,0,255);
    strcpy(FILE_TO_CHMOD,pathName);

    char *REMOTE_URL=new char[255];
    memset(REMOTE_URL,0,255);
    strncpy(REMOTE_URL,URL,strlen(URL));---->URL will be filled as soon
as Connect fucntion is called which we do first
                                                           before
calling ChmodRemoteFile() fucntion

    sprintf(mode_to_change,"%d",mode);
    if(strcmp(TYPE,"SFTP")==0)
    {
    strcpy(buf_5,"chmod ");
    }
    else
    strcpy(buf_5,"SITE CHMOD ");
    strcat(buf_5,mode_to_change);
    strcat(buf_5," ");
    strcat(buf_5,FILE_TO_CHMOD);

    if(curl)
    {
        cout<<"value of buf5"<<buf_5<<endl;
        curl_easy_setopt(curl, CURLOPT_VERBOSE,1);
        headerlist = curl_slist_append(headerlist, buf_5);
        curl_easy_setopt(curl, CURLOPT_POSTQUOTE, headerlist);
        curl_easy_setopt(curl, CURLOPT_URL,REMOTE_URL);
        res = curl_easy_perform(curl);
        cout<<"value of res in ChmodRemoteFile is : "<<res<<endl;
        if(res!=0)
        {
            errorStatus=21;
        }
    }

Regards
Nagarajan
>>> Dan

--
http://www.MoveAnnouncer.com              The web change of address
service
          Let webmasters know that your web site has moved
Please do not print this email unless it is absolutely necessary. 

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. 

www.wipro.com
Received on 2008-06-27

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET