Test if a linux command is available with Spawn [message #86171] |
Wed, 16 October 2013 05:08  |
Fabzi
Messages: 305 Registered: July 2010
|
Senior Member |
|
|
Hi IDLers,
I want to write a clipboard copy/paste function with IDL on Linux
systems. This is really straightforward with xclip. I just need to know
if the system I am working on has xclip installed. Based on
cgHasImageMagick, I could do:
IDL> Spawn, 'xclip -version', result, error_result
But xclip returns the version in the STDERR stream:
IDL> print, result
IDL> print, error_result
xclip version 0.12 Copyright (C) 2001-2008 Kim Saunders et al.
Distributed under the terms of the GNU GPL
This ok for me, but how to be sure that this is the case on all linux
systems?
Is there a "more general way" to do this?
Thanks a lot,
Fabien
|
|
|
|
|
|
Re: Test if a linux command is available with Spawn [message #86209 is a reply to message #86171] |
Thu, 17 October 2013 09:25   |
chris_torrence@NOSPAM
Messages: 528 Registered: March 2007
|
Senior Member |
|
|
On Wednesday, October 16, 2013 6:08:51 AM UTC-6, Fabien wrote:
> Hi IDLers,
>
>
>
> I want to write a clipboard copy/paste function with IDL on Linux
>
> systems. This is really straightforward with xclip. I just need to know
>
> if the system I am working on has xclip installed. Based on
>
> cgHasImageMagick, I could do:
>
>
>
> IDL> Spawn, 'xclip -version', result, error_result
>
>
>
> But xclip returns the version in the STDERR stream:
>
>
>
> IDL> print, result
>
>
>
> IDL> print, error_result
>
> xclip version 0.12 Copyright (C) 2001-2008 Kim Saunders et al.
>
> Distributed under the terms of the GNU GPL
>
>
>
> This ok for me, but how to be sure that this is the case on all linux
>
> systems?
>
>
>
> Is there a "more general way" to do this?
>
>
>
> Thanks a lot,
>
>
>
> Fabien
Hi Fabien,
If you are just looking to copy/paste text (not images or files), and you can wait until IDL 8.3, we are adding routines to provide access to the system clipboard (text only) on all platforms.
Cheers,
Chris
VIS
|
|
|
Re: Test if a linux command is available with Spawn [message #86211 is a reply to message #86173] |
Thu, 17 October 2013 11:30   |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
On 10/16/13 8:12 AM, Phillip Bitzer wrote:
> How about spawning "which", which should fairly standard on *nix:
>
> spawn, 'which xclip', result
>
I would check the EXIT_STATUS on "which xclip":
IDL> spawn, 'which xclip', stdout, stderr, exit_status=xclip_error
IDL> help, xclip_error
XCLIP_ERROR LONG = 1
Error code not 1 means there was a problem, in this case I don't have
xclip. If I have the program, it's like this:
IDL> spawn, 'which ls', stdout, stderr, exit_status=ls_error
IDL> help, ls_error
LS_ERROR LONG = 0
In this case, I don't need stdout/stderr output, but calling SPAWN with
them suppresses output to the output log.
Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
Research Mathematician
Tech-X Corporation
|
|
|
|