Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8709493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:22:31+00:00 2026-06-13T04:22:31+00:00

I need to copy the zip files from local machine and paste in remote

  • 0

I need to copy the zip files from local machine and paste in remote machine and unzip those files in remote machine.

I know the first part can be done using the scp (copy zip files from local and paste in remote machine) but how to do the second part using ant?

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:22:32+00:00Added an answer on June 13, 2026 at 4:22 am

    You could use the sshexec task to call the command line unzip command on the remote machine (assuming the remote machine has unzip installed).

    <!-- local directory containing the files to copy -->
    <property name="archives" location="C:\path\to\zipfiles" />
    <property name="archives.destination" value="/home/testuser/archives" />
    <property name="unzip.destination" value="/home/testuser/unpacked" />
    
    <fileset id="zipfiles.to.copy" dir="${archives}" includes="*.zip" />
    
    <!-- copy the archives to the remote server -->
    <scp todir="${user}:${password}@host.example.com:${archives.destination}">
      <fileset refid="zipfiles.to.copy" />
    </scp>
    
    <!-- Build the command line for unzip - the idea here is to turn the local
         paths into the corresponding paths on the remote, i.e. to turn
         C:\path\to\zipfiles\file1.zip;C:\path\to\zipfiles\file2.zip... into
         /home/testuser/archives/file1.zip /home/testuser/archives/file2.zip
    
         For this to work there must be no spaces in any of the zipfile names.
    -->
    <pathconvert dirsep="/" pathsep=" " property="unzip.files" refid="zipfiles.to.copy">
      <map from="${archives}" to="${archives.destination}" />
    </pathconvert>
    
    <!-- execute the command.  Use the "-d" option to unzip so it will work
         whatever the "current" directory on the remote side -->
    <sshexec host="host.example.com" username="${user}" password="${password}"
      command="/bin/sh -c '
        for zipfile in ${unzip.files}; do
          /usr/bin/unzip -d ${unzip.destination} $$zipfile ; done '" />
    

    The unzip command can take a number of other options, see its man page for full details. For example the -j option will ignore any directory hierarchy inside the zip files and put all the extracted files directly in the target directory. And -o will force overwrite existing files in the target directory without prompting.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to copy several files to remote server. for database in `mysql -Bseshow
I need to get a zip file from an email attachment, unzip it and
I need to copy files and directories within a directory. Suppose there is only
I need to copy all *.exe files in some directory to other virtual drive
I need to copy a node and its sub-nodes: first: one identical copy followed
I need to copy files in one directory to another directory where the lastwritetime
I need to copy a jar file from one directory to another when my
I need to copy a table from one server to another.for that I have
I need to copy hundreds of gigs of random files around on my computer
I need to copy two linked lists recursively and return a new list .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.