Java Mailing List Archive

http://www.ant-tasks.com/

Home » Ant Users List »

AW: Using environment variable in SCP

Jan Materne

2008-03-18

Replies:
I thought you want to use the env variable in your "scp"
<sshexec trust="true"
 host="${host}"
 username="${remote.user}"
 password="${remote.password}"
 command="cp -rvf /tmp/solr/${webapp.name} $SOLR_PATH"
 failonerror="true"/>

(maybe you have to mask the $ by $$).

You could also start Ant with -v(erbose) or -d(ebug) mode.
Usually you'll see the command Ant tries to execute.


Jan


> -----Ursprüngliche Nachricht-----
> Von: Suhas Majale [mailto:suhasrm@(protected)]
> Gesendet: Dienstag, 18. März 2008 09:36
> An: Ant Users List
> Betreff: Re: Using environment variable in SCP
>
> Hi Jan,
>
> Thanks for the reply and the work around you suggested.
> I am copying the files in the /tmp/solr folder and using the
> sshexec to copy
> the directory from /tmp/solr to $SOLR_HOME (/root/solr-deploy/solr/)
> Here is my piece of ant script.
>
> *<scp
> remoteTodir="${remote.user}:${remote.password}@(protected)}"
> trust="true" sftp="true">
> <fileset dir="solr"/>
> </scp>
> <sshexec trust="true"
>  host="${host}"
>  username="${remote.user}"
>  password="${remote.password}"
>  command="cp -rvf /tmp/solr/${webapp.name} ${solr.home.path}"
>  failonerror="true"/> *
> **
> Now when I do this, I get the following error
>
> *remote-copy-solr-files:
>  [scp] Connecting to 192.168.0.130:22
>  [scp] done.
>  [sshexec] Connecting to 192.168.0.130:22
>  [sshexec] cp: missing destination file operand after
> `/tmp/solr/test1'
>  [sshexec] Try `cp --help' for more information.*
>
> When I give the command as *"cd ${solr.home.path}"* it works,
> but it do not
> work when used with *cp*
> **
> Also form the shell prompt it works.
> *cp -rf /tmp/solr/test1 $SOLR_PATH*
> **
> So is it something it has to do with the cp command?
>
> Regards, Suhas M.
>
> On Tue, Mar 18, 2008 at 12:16 PM, <Jan.Materne@(protected):
>
> > When working with remote tasks like <scp> we have to distinguish
> > between two environments: the env from the local and the
> remote machine.
> >
> > You can use the local environment by loading them into properties.
> >   <property environment="env"/>
> >   <scp remoteTodir="${remote.user}:${remote.password}@(protected)}:${
> > env.SOLR_HOME}/">
> >
> > I dont think that you can use the remote environment.
> > What you could do as workaround is
> >   1. <scp> to a tmp directory
> >   2. <sshexec> to move the files
> > Because the <sshexec> works on the remote machine you
> should have access
> > the the
> > remote environment variables.
> >
> >
> > Jan
> >
> >
> > > -----Ursprüngliche Nachricht-----
> > > Von: Suhas Majale [mailto:suhasrm@(protected)]
> > > Gesendet: Dienstag, 18. März 2008 07:08
> > > An: user@(protected)
> > > Betreff: Using environment variable in SCP
> > >
> > > HI all,
> > >
> > > I am very new to ant and am using the SCP to transfer files
> > > from windows to
> > > linux (FC 6) machine.
> > > Following is the code,
> > >
> > > *<scp remoteTodir="${remote.user}:${remote.password}@(protected)}:${
> > > solr.home.path}/" trust="true" sftp="true">*
> > > *<fileset dir="solr"/>
> > > </scp>**
> > > *
> > > The *solr.home.path* is getting read from the associated
> > > properties file.
> > > When I assign absolute path for solr.home.path the transfer works
> > > successfully.
> > > i.e *solr.home.path=/root/solr-deploy/solr*
> > >
> > > Now instead of giving the absolute path, I tried giving
> > > environment variable
> > > that is set for that path. When I do so, the transfer fails.
> > > *solr.home.path=$SOLR_HOME*
> > >
> > > Can we use environment variable in SCP ? If yes, what is the
> > > way we do it?
> > >
> > > Regards, Suhas M
> > >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@(protected)
> > For additional commands, e-mail: user-help@(protected)
> >
> >
>
>
> --
> --------------------------------------------------------------
> --------------------------------------------------------------
> ----------
> Regards, Suhas Majale
> Developers - we trust, rest - we test.
>
> Mobile: +91 988 667 9108
> Off Direct: +91 80 4178 9139
> http://www.CoreObjects.com
> --------------------------------------------------------------
> --------------------------------------------------------------
> ----------
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.