Return-Path: Delivered-To: apmail-jakarta-ant-user-archive@jakarta.apache.org Received: (qmail 82584 invoked by uid 500); 27 Jul 2001 19:35:44 -0000 Mailing-List: contact ant-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: ant-user@jakarta.apache.org Delivered-To: mailing list ant-user@jakarta.apache.org Received: (qmail 82565 invoked from network); 27 Jul 2001 19:35:44 -0000 Message-ID: <20010727193547.48908.qmail@web9701.mail.yahoo.com> Date: Fri, 27 Jul 2001 12:35:47 -0700 (PDT) From: Don Taylor Subject: Re: Using Ant with SSH To: ant-user@jakarta.apache.org In-Reply-To: <3B619CB3.7000705@sedonacorp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N This task works great as long as you're not logging. That's why I've created a Swing-based task to handle getting input. If anyone's interested, let me know and I'll send it to you. -- Don --- Matthew Inger wrote: > why not? what's wrong with prompting the user for input? > > I'll even supply the task................ (see attachment) > > > Filip Cruz wrote: > > > Thanks, Paul > > I'll give it a try. > > > > At 11:36 AM 7/26/2001 -0400, you wrote: > > > >> I'm doing SSH deployment using SecureCRT. > >> SecureCRT has VCP command line utility to transfer files over SSH. > >> One problem - you can't input password during deployment so I'm > >> providing it > >> in a password file. > >> > >> Here is an example of target: > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> Good luck, > >> > >> Paul Perevalov, > >> Bridium,Inc. > >> > >> -----Original Message----- > >> From: Filip Cruz [mailto:fcruz@camail.harvard.edu] > >> Sent: Thursday, July 26, 2001 11:18 AM > >> To: ant-user@jakarta.apache.org > >> Subject: Re: Using Ant with SSH > >> > >> > >> Sorry, > >> I am trying to use Ant to deploy to our production servers through > > >> SSH. In > >> brief I want to be able to deploy the files over SSH to the server > > >> from a > >> task in the Ant build.xml file. I am using a Win2K client and I > have SSH > >> Secure Shell client and SecureCRT. > >> > >> Is there a way to deploy over SSH from Ant?? If so, how is it > done? > > > > > > > > > > > > /* > > ****************************************************************************** > * $RCSfile: Prompt.java,v $ $Revision: 1.3 $ $Date: 2001/06/15 > 20:30:57 $ > > ****************************************************************************** > */ > import org.apache.tools.ant.BuildException; > import org.apache.tools.ant.Project; > import org.apache.tools.ant.Task; > import java.io.LineNumberReader; > import java.io.InputStreamReader; > import java.io.IOException; > import java.util.ArrayList; > import java.util.List; > > /*** > * Task definition for the ANT task to prompt the user for > information > * Usage: > * > * Task declaration in the project: > * > * > * Task calling syntax: > * * [defaultvalue="value" | allowempty="true|false"] > * > > * [ * > * > * Attributes: > * message -> The message to display to the user > * propertyname -> The name of the property to set with the > received input > * defaultValue -> The default value if the user just hits > enter > * allowempty -> Whether or not an empty value is allowed > * > * Subitems: > * --> allow this value to be input. > By supplying > * one or more of this subitem, > you limit the > * input to a range of specific > allowable > * values. Any value input that > is not explicitly > * allowed is rejected. (good for > y/n questions) > * > * Notes: > * 1. The defaultvalue and allowempty attributes are mutually > exclusive, > * and if both are specified, the defaultvalue attribute > takes precedence. > */ > public class Prompt extends Task > { > private String message; > private String defaultValue; > private String propertyName; > private boolean allowEmpty; > private List allows; > > /*** > * Default Constructor > */ > public Prompt() > { > allows = new ArrayList(); > allowEmpty = true; > } > > public void execute() > throws BuildException > { > if (message == null) > throw new BuildException("Message is missing"); > if (propertyName == null) > throw new BuildException("PropertyName is missing"); > > if (defaultValue != null && allows.size() > 0) > { > if (! allows.contains(new Allow(defaultValue))) > throw new BuildException("Default Value is not in the > set of allowed values."); > } > > StringBuffer sb = new StringBuffer(); > sb.append(message); > sb.append(" "); > > int asize = allows.size(); > if (asize > 0) > { > sb.append(" ("); > for (int i=0;i { > if (i != 0) sb.append(','); > sb.append(allows.get(i)); > } > sb.append(") "); > } > > if (defaultValue != null) > { > sb.append('['); > sb.append(defaultValue); > sb.append(']'); > sb.append(" : "); > } > > boolean done = false; > LineNumberReader lnr = new LineNumberReader(new > InputStreamReader(System.in)); > > String inputValue = ""; > > while (! done) > { > System.out.print(sb.toString()); > > try > { > inputValue = lnr.readLine(); > > if ((defaultValue != null) && > (inputValue.trim().length() == 0)) > { > inputValue = defaultValue; > done = true; > } > else if (allows.size() > 0) > { > if (allows.contains(new Allow(inputValue)) || > (defaultValue != null && > inputValue.trim().equals(defaultValue))) > { > done = true; > } > } > else > { > done = true; > } > } > catch (IOException e) > { > throw new BuildException(e); > } > > if (defaultValue != null && inputValue.trim().length() == > 0) > { > inputValue = defaultValue; > } > > if (! allowEmpty && inputValue.trim().length() == 0) > done = false; > > if (! done) > System.out.println(" Invalid value: '" + inputValue > + "'"); > } > > Project p = getProject(); > p.setUserProperty(propertyName, inputValue); > } > > /*** > * Sets the prompt message > */ > public void setMessage(String message) > { > this.message = message; > } > > /*** > * Sets the defaultValue that is used if the user just hits > return > */ > public void setDefaultValue(String defaultValue) > { > this.defaultValue = defaultValue; > } > > public void setAllowEmpty(String allowEmpty) > { > try > { > this.allowEmpty = > Boolean.valueOf(allowEmpty).booleanValue(); > } > catch (Exception e) > { > this.allowEmpty = true; > } > } > > === message truncated === __________________________________________________ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/