Efault

This is a discussion on Efault within the C Programming forums, part of the General Programming Boards category; Hello, I running the following command from 'server'; I am using the command system( "rcp /home/user/[1-3]??? machine1:/location/" ); I run ...

  1. #1
    Unregistered
    Guest

    Efault

    Hello,
    I running the following command from 'server';

    I am using the command system( "rcp /home/user/[1-3]??? machine1:/location/" ); I run this command as root.

    However, I cannot seem to copy the desired files.

    Also, 'machine1' has file .rhosts which says 'server root';

    Also, the errno is 14(EFAULT).

    Can anyone help me why I'm getting this fault? Also, if I run this command at the prompt I can copy the files i.e. no problem.

    Thanks in advance.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,554
    I think that this is the problem

    /home/user/[1-3]???

    When you type this on the command line, it is the shell which performs the wildcard expansion - not the program.

    I don't know whether the same expansion happens when you use the system() function - personally, I would think not.

    Try using system with a specific named file.

    > Also, the errno is 14(EFAULT).
    You'd have to post some code.
    EFAULT just means 'bad address', which covers a multitude of sins.

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    23
    here's my code, please keep in mind that I'm using a really old compiler. Also, I don't know what version I'm using.

    by the way, even with "system("ls");" errno is still 14 i.e. EFAULT
    incredible isn't it???



    copyfile( sTester, apTester )
    int sTester;
    char *apTester[];
    {
    int status;
    char *tmp;

    tmp = (char *)malloc(sizeof(char) * GETTEMP );


    while( 1 )
    {
    if( sTester < 0 )
    return 0;
    else if( sTester >= 0 )
    {
    memset( tmp,0,sizeof(tmp));

    strcpy( tmp,"rcp /home/user1/[1-3]??? " );
    strcat( tmp,apTester[sTester] );
    strcat( tmp,":/hp3070/autofile/" );

    #if 0
    printf( "|%s|\n",tmp );

    puts( tmp );getchar();
    printf(" errorno is %d",errno);

    system( tmp );
    #endif
    status = system( "ls" );
    printf("\n here errorno is %d %d",errno,status );getchar();
    system( "rcp //home//user1//[1-3]??? hpfem1a://hp3070//autofile" );


    memset( tmp,0,sizeof(tmp));
    strcpy( tmp,"remsh " );
    strcat( tmp,apTester[sTester] );
    strcat( tmp," chmod 775 /hp3070/autofile/[1-3]???" );
    #if 0
    /* puts( tmp );*/
    #endif
    system( tmp );

    memset( tmp,0,sizeof(tmp));
    strcpy( tmp,"remsh " );
    strcat( tmp,apTester[sTester] );
    strcat( tmp," chown root:sys /hp3070/autofile/[1-3]???" );
    #if 0
    /* puts( tmp );*/
    #endif
    system( tmp );


    }

    sTester = sTester - 1;

    }

    memset( tmp,0,sizeof(tmp));
    strcpy( tmp,"rm -f /home/user1/[1-3]???" );
    system( tmp );
    #if 0
    /* puts( tmp );*/
    #endif


    return 1;

    }


    thanks for any tips/help

  4. #4
    Registered User
    Join Date
    Nov 2001
    Posts
    23
    actually, there more code and I think it's got something to do with pointers.
    I think I'll have to debug it really slowly...

    thanks anyway

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    > strcpy( tmp,"rm -f /home/user1/[1-3]???" );
    > system( tmp );

    Why bother?

    system( "rm -f /home/user1/[1-3]???" );

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21