Looks like the output of java -version is printed to stderr and not stdout.
This output should be accessible from the stderr attribute of the return
value of run: version.stderr.

There is more information in the documentation here:
http://docs.fabfile.org/en/1.0.1/api/core/operations.html#fabric.operations.run
<http://docs.fabfile.org/en/1.0.1/api/core/operations.html#fabric.operations.run>and
here:
http://docs.fabfile.org/en/1.0.1/usage/interactivity.html#combine-streams

<http://docs.fabfile.org/en/1.0.1/usage/interactivity.html#combine-streams>I
hope this helps.

On Wed, Jun 1, 2011 at 05:15, Kaushal Shriyan <[email protected]>wrote:

> Hi,
>
> I have the below fabric script
>
> #!/usr/bin/env python
> from fabric.api import *
>
> out_log = open("output.txt", "w")
>
> with open("hosts.txt") as host_file:
>        host_list = [x.strip() for x in host_file.readlines()]
>
> @hosts(host_list)
> def java_version():
>        with settings(warn_only=True):
>            version = run("java -version")
>        out_log.write("%s: %s" % (env.host, version))
> kaushal@kaushal-laptop:~$ fab ^C
> kaushal@kaushal-laptop:~$ fab java_version
> [10.30.0.10] Executing task 'java_version'
> [10.30.0.10] run: java -version
> Password for [email protected]:
> [10.30.0.10] err: java version "1.6.0_06"
> [10.30.0.10] err: Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
> [10.30.0.10] err: Java HotSpot(TM) 64-Bit Server VM (build 10.0-b22, mixed
> mode)
>
> Done.
> Disconnecting from 10.30.0.10... done.
> kaushal@kaushal-laptop:~$ cat output.txt
> 10.30.0.10: kaushal@kaushal-laptop:~$
>
> When i look at the output.txt i dont see the version name as against
> the hostname. Please suggest/guide.
>
> Regards,
>
> Kaushal
>
> _______________________________________________
> Fab-user mailing list
> [email protected]
> https://lists.nongnu.org/mailman/listinfo/fab-user
>



-- 
Venlig hilsen / Kind regards,
Christian Vest Hansen.
_______________________________________________
Fab-user mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/fab-user

Reply via email to