• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Ant scp task giving Error

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have one requirement, to copy the local files to remote system.
I have done the following steps:

download the jsch-0.1.40.jar;
E:\AntTest>set path=E:\AntTest\jsch-0.1.40.jar;%path%;
E:\AntTest>set classpath=E:\AntTest\jsch-0.1.40;%classpath%;


E:\AntTest>ant copyFileToRemote
Buildfile: build.xml

copyFileToRemote:
[echo] 2222222222 copyFileToRemote Examples:::::::::::::

BUILD FAILED
E:\AntTest\build.xml:28: Could not create task or type of type: scp.
Ant could not find the task or a class this task relies upon.
This is common and has a number of causes; the usual
solutions are to read the manual pages then download and
install needed JAR files, or fix the build file:
- You have misspelt 'scp'.
Fix: check your spelling.
- The task needs an external JAR file to execute
and this is not found at the right place in the classpath.
Fix: check the documentation for dependencies.
Fix: declare the task.
- The task is an Ant optional task and the JAR file and/or libraries
implementing the functionality were not found at the time you
yourself built your installation of Ant from the Ant sources.
Fix: Look in the ANT_HOME/lib for the 'ant-' JAR corresponding to the
task and make sure it contains more than merely a META-INF/MANIFEST.MF.
If all it contains is the manifest, then rebuild Ant with the needed
libraries present in ${ant.home}/lib/optional/ , or alternatively,
download a pre-built release version from apache.org
- The build file was written for a later version of Ant
Fix: upgrade to at least the latest release version of Ant
- The task is not an Ant core or optional task
and needs to be declared using <taskdef>.
- You are attempting to use a task defined using
<presetdef> or <macrodef> but have spelt wrong or not
defined it at the point of use

The Build file as follows:

<project name="ImportedBuild" default="all">
<target name="copyFileToRemote">
<echo>2222222222 copyFileToRemote Examples:::::::::::::</echo>
<scp file="sample.txt" todir="${username}:${password}@${hostname}:/shared"/>
</target>
</project>


Could you please give me any solution to resolve this issus and provide any examples . It would be great help to me.

Regards,
Sam
 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Sasank,

There are two possibilities:

1)

the "jsch-0.1.40.jar" file is not working. means i also face this problem. that i do have this jar in my lib folder but still its not working.
so try to seprately download a newer jsc.jar and then place it in your classpath.

2)

you said you need the sample code so here is my sample code :



Regards,
 
sasank ch
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Amir,

Thank you for your Replay.

Could you please let me know, Where will i get the antlib.xml.

I think, because of the xml file missing, I am getting the following error:
Could not create task or type of type: trycatch.

<taskdef resource="net/sf/antcontrib/antlib.xml" />

Regards,
Sasank
 
Ranch Hand
Posts: 470
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need ant-contrib-version.jar http://ant-contrib.sourceforge.net/tasks/index.html
 
Villains always have antidotes. They're funny that way. Here's an antidote disquised as a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!