#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2011
    Posts
    1
    Rep Power
    0

    Deleting multiple files in remote box via sh


    Requirement
    Several files in remote machines ought to be deleted via sh. Name of the files to be deleted are know



    Approach
    1) script was written with ftp (requires credential) and delete command. File names were passed as array(iterated via for loop-with ftp+delete commands enclosed within for loop). files were not getting deleted by this approach



    2) another approach attempted was to pass temp.ftp(which contains delete command) to ftp command and rm the temp.ftp file eg.ftp <<temp.ftp..but this would be sucessful for open ftp which doenst require credentials



    Request

    require pointers to delete muliple files in remote machine via shell script
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2006
    Posts
    834
    Rep Power
    387

    Talking ssh...


    1) Setup ssh connectivity (exchange ssh keys).

    2) Use ssh to remove the files:
    Code:
    cat fileList.tmp|ssh -C $TGTHOST \"rm -f - \" "

IMN logo majestic logo threadwatch logo seochat tools logo