bash query
Tony Arnold
tony.arnold at manchester.ac.uk
Sun Jun 3 13:46:16 UTC 2007
James,
James Takac wrote:
> On Sunday 03 June 2007 19:23:34 Andy wrote:
>> On 03/06/07, dave selby <dave6502 at googlemail.com> wrote:
>>> #!/bin/bash
>>> read KEY
>>> if [ $KEY = "q" ];
>>> then
>>> echo "a QQQQQQQQQQQQQQQ"
>>> fi
>>> [snip]
>>> dave at dev-machine:~$ ./test.sh
>>>
>>> ./test.sh: line 5: [: =: unary operator expected
>>> dave at dev-machine:~$
>> Use "$KEY" instead of $KEY , that way if $KEY has no value it
>> evaluates to the empty string ""
>>
>>
>>
>> --
>> First they ignore you
>> then they laugh at you
>> then they fight you
>> then you win.
>> - Mohandas Gandhi
>
> Hi Guys
>
> Thought I'd ask here re something I'm trying to do as it kinda relates to the
> subject. Anyone know if you can pipe a command to a terminal session in a
> script? I'm hoping for the script to open a terminal, pipe a command to it,
> then when finished close the terminal window
Most terminal window commands, e.g., xterm, rxvt, gnome-terminal, take
an option that specifies a command to execute in the terminal window. If
you want to do piping etc, then you probably have to invoke bash and
give that the command(s) you want executed, e.g.,
gnome-terminal -e 'bash -c "ls -lh"'
or something similar!
Regards,
Tony.
--
Tony Arnold, IT Security Coordinator, University of Manchester,
IT Services Division, Kilburn Building, Oxford Road, Manchester M13 9PL.
T: +44 (0)161 275 6093, F: +44 (0)870 136 1004, M: +44 (0)773 330 0039
E: tony.arnold at manchester.ac.uk, H: http://www.man.ac.uk/Tony.Arnold
More information about the ubuntu-users
mailing list