yılında
Teşekkürler (yüklü unzip uzak makineyi etti varsayarak).
<!-- 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 '" />
unzip
komut, diğer bir dizi seçeneği almak onun man page tüm detaylar için görebilirsiniz. Örneğin, -j
seçeneği, zip dosyaları içindeki herhangi bir dizin hiyerarşisini yok sayar ve çıkartılan tüm dosyaları doğrudan hedef dizine koyar. Ve -o
, hedef dizinde varolan dosyaları üzerine sormadan zorlayacaktır. i belli bir dir tüm dosyaları halletmek ve sshexec kullanarak someother dir olanlar Çýkartýlan dosyasını koymak gereken yere
bana örnek vermek misiniz? – coolgokul
@coolgokul Bir (umarım kapsamlı) örnek ekledim. –
müthiş harika. iyi çalışıyor. iki soru. 1. Bu program bir klasördeki tüm dosyaları unzip ve ayıklanan dosyaları bir dizine taşımak için nasıl yapılır. 2. Eğer dosyalar zaten hedef direk fermuarlı ise ve tekrar unzip etmeye çalışırsanız dosyaları değiştirmek ister misiniz? Dosyaları değiştirmek için her zaman evet nasıl ayarlanır? şimdiden teşekkürler. – coolgokul