You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Suhas Majale <su...@gmail.com> on 2008/03/18 07:07:47 UTC
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}@${host}:${
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
Re: Using environment variable in SCP
Posted by Suhas Majale <su...@gmail.com>.
HI Steve,
Thanks for your reply, it was the same problem that you anticipated.
It was not loading the env variables, so I had a workaround for that.
Now my code works like this, I am setting the environment variable in the
.bash_profile and here is working piece of my code.
*<target name="remote-copy-solr-files"
depends="check-solrpath,copy_solr_files">
<scp remoteTodir="${remote.user}:${remote.password}@${host}:${tmp.path}"
trust="true" sftp="true">
<fileset dir="solr"/>
</scp>*
* <sshexec trust="true"
host="${host}"
username="${remote.user}"
password="${remote.password}"
command="(. .bash_profile ; mv /tmp/${webapp.name} $SOLR_PATH)"
failonerror="true"/>
*
Regards, Suhas M
On Tue, Mar 18, 2008 at 3:54 PM, Steve Loughran <st...@apache.org> wrote:
> Suhas Majale wrote:
> > I am using properties file, in which *solr.home.path=$SOLR_PATH*
> >
> > Even it fails when I try with
> >
> > command="cp -rvf /tmp/solr/${webapp.name} $SOLR_PATH"
> > or
> > command="cp -rvf /tmp/solr/${webapp.name} $$SOLR_PATH"
> > or
> > command="cp -rvf /tmp/solr/${webapp.name} $$SOLR_PATH"
> >
> > Regards, Suhas M.
> >
>
> The issue here is that when you SSH in, you may not be running a login
> shell (as in bash -login), so env variables set in .bashrc /etc/profile
> may not be set.
>
> 1. add an echo $SOLR_PATH to your command list
> 2. force load whichever file sets the environment variables, with
> something like
> source ~/.bashrc
> (thats the tcsh operation; I dont use bash enough to be sure the
> syntax is correct. It may be
> . ~/.bashrc
> 3. drive everything from property files in your local system
>
>
> --
> Steve Loughran http://www.1060.org/blogxter/publish/5
> Author: Ant in Action http://antbook.org/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
--
Regards, Suhas Majale.
Re: Using environment variable in SCP
Posted by Steve Loughran <st...@apache.org>.
Suhas Majale wrote:
> I am using properties file, in which *solr.home.path=$SOLR_PATH*
>
> Even it fails when I try with
>
> command="cp -rvf /tmp/solr/${webapp.name} $SOLR_PATH"
> or
> command="cp -rvf /tmp/solr/${webapp.name} $$SOLR_PATH"
> or
> command="cp -rvf /tmp/solr/${webapp.name} $$SOLR_PATH"
>
> Regards, Suhas M.
>
The issue here is that when you SSH in, you may not be running a login
shell (as in bash -login), so env variables set in .bashrc /etc/profile
may not be set.
1. add an echo $SOLR_PATH to your command list
2. force load whichever file sets the environment variables, with
something like
source ~/.bashrc
(thats the tcsh operation; I dont use bash enough to be sure the
syntax is correct. It may be
. ~/.bashrc
3. drive everything from property files in your local system
--
Steve Loughran http://www.1060.org/blogxter/publish/5
Author: Ant in Action http://antbook.org/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Using environment variable in SCP
Posted by Suhas Majale <su...@gmail.com>.
I am using properties file, in which *solr.home.path=$SOLR_PATH*
Even it fails when I try with
command="cp -rvf /tmp/solr/${webapp.name} $SOLR_PATH"
or
command="cp -rvf /tmp/solr/${webapp.name} $$SOLR_PATH"
or
command="cp -rvf /tmp/solr/${webapp.name} $$SOLR_PATH"
Regards, Suhas M.
On Tue, Mar 18, 2008 at 2:31 PM, <Ja...@rzf.fin-nrw.de> wrote:
> 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@gmail.com]
> > 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}@${host}:${tmp.path}"
> > 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, <Ja...@rzf.fin-nrw.de> wrote:
> >
> > > 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}@${host}:${
> > > 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@gmail.com]
> > > > Gesendet: Dienstag, 18. März 2008 07:08
> > > > An: user@ant.apache.org
> > > > 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}@${host}:${
> > > > 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@ant.apache.org
> > > For additional commands, e-mail: user-help@ant.apache.org
> > >
> > >
> >
> >
> > --
> > --------------------------------------------------------------
> > --------------------------------------------------------------
> > ----------
> > Regards, Suhas Majale
> > Developers - we trust, rest - we test.
> >
> > Mobile: +91 988 667 9108
> > Off Direct: +91 80 4178 9139
> > http://www.CoreObjects.com <http://www.coreobjects.com/>
> > --------------------------------------------------------------
> > --------------------------------------------------------------
> > ----------
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
--
--------------------------------------------------------------------------------------------------------------------------------------
Regards, Suhas Majale
Developers - we trust, rest - we test.
Mobile: +91 988 667 9108
Off Direct: +91 80 4178 9139
http://www.CoreObjects.com
--------------------------------------------------------------------------------------------------------------------------------------
AW: Using environment variable in SCP
Posted by Ja...@rzf.fin-nrw.de.
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@gmail.com]
> 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}@${host}:${tmp.path}"
> 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, <Ja...@rzf.fin-nrw.de> wrote:
>
> > 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}@${host}:${
> > 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@gmail.com]
> > > Gesendet: Dienstag, 18. März 2008 07:08
> > > An: user@ant.apache.org
> > > 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}@${host}:${
> > > 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@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org
> >
> >
>
>
> --
> --------------------------------------------------------------
> --------------------------------------------------------------
> ----------
> 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@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Using environment variable in SCP
Posted by Suhas Majale <su...@gmail.com>.
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}@${host}:${tmp.path}"
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, <Ja...@rzf.fin-nrw.de> wrote:
> 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}@${host}:${
> 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@gmail.com]
> > Gesendet: Dienstag, 18. März 2008 07:08
> > An: user@ant.apache.org
> > 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}@${host}:${
> > 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@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
--
--------------------------------------------------------------------------------------------------------------------------------------
Regards, Suhas Majale
Developers - we trust, rest - we test.
Mobile: +91 988 667 9108
Off Direct: +91 80 4178 9139
http://www.CoreObjects.com
--------------------------------------------------------------------------------------------------------------------------------------
AW: Using environment variable in SCP
Posted by Ja...@rzf.fin-nrw.de.
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}@${host}:${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@gmail.com]
> Gesendet: Dienstag, 18. März 2008 07:08
> An: user@ant.apache.org
> 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}@${host}:${
> 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@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org