FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 12-01-2009, 08:57 AM
Loc Greni
 
Default Executing a command named in a variable

2009/12/1 Ray Parrish <crp@cmc.net>:
> Hello,
>
> I'm thinking of a way to set a default external editor in a bash program
> I am writing, and need to know if it is possible to execute a command
> named in a variable that gets set by retrieving the command line for the
> external editor's command line from a configuration file.
>
> Would the following work?
>
> # set variable to command line
> ExecuteEditor="/usr/bin/gedit filename.ext"
> # execute external command.
> $ExecuteEditor &
>
> If this does not work, is there any other way to retireve the command
> line of an external command and run it?

It should work. You have also the builtin command "eval" that
evaluates the command. eval has also the effect of interpreting
$, `, etc... so it is different than just $ExecuteEditor.

Loc

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-01-2009, 09:35 AM
Nils Kassube
 
Default Executing a command named in a variable

Ray Parrish wrote:
> Would the following work?
>
> # set variable to command line
> ExecuteEditor="/usr/bin/gedit filename.ext"
> # execute external command.
> $ExecuteEditor &

No, it wouldn't work because bash will look in /usr/bin for a command
"gedit filename.ext" which doesn't exist. You would need the eval
command here but you might as well write it this way:

ExecuteEditor=/usr/bin/gedit
File=filename.ext
$ExecuteEditor $File &


Nils

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-01-2009, 10:10 AM
Loc Greni
 
Default Executing a command named in a variable

2009/12/1 Nils Kassube <kassube@gmx.net>:
> Ray Parrish wrote:
>> Would the following work?
>>
>> # set variable to command line
>> ExecuteEditor="/usr/bin/gedit filename.ext"
>> # execute external command.
>> $ExecuteEditor &
>
> No, it wouldn't work because bash will look in /usr/bin for a command
> "gedit filename.ext" which doesn't exist. You would need the eval
> command here but you might as well write it this way:

Did you try before answering ? It works.

Loc

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-01-2009, 10:44 AM
Avi Greenbury
 
Default Executing a command named in a variable

Ray Parrish wrote:

> Hello,
>
> I'm thinking of a way to set a default external editor in a bash
> program I am writing, and need to know if it is possible to execute a
> command named in a variable that gets set by retrieving the command
> line for the external editor's command line from a configuration file.
>
> Would the following work?
>
> # set variable to command line
> ExecuteEditor="/usr/bin/gedit filename.ext"
> # execute external command.
> $ExecuteEditor &

Yes, assuming you mean bash.

Did you try it? It's not something that's particularly dangerous to try.

It's worth checking for the existence of the $EDITOR environment
variable, first, as this is where the user would be expected to have
declared their preference for vim^H^H^H their favourite text editor.



--
Avi Greenbury
http://aviswebsite.co.uk
http://aviswebsite.co.uk/asking-questions

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-01-2009, 10:45 AM
Nils Kassube
 
Default Executing a command named in a variable

Loc Greni wrote:
> 2009/12/1 Nils Kassube <kassube@gmx.net>:
> > Ray Parrish wrote:
> >> Would the following work?
> >>
> >> # set variable to command line
> >> ExecuteEditor="/usr/bin/gedit filename.ext"
> >> # execute external command.
> >> $ExecuteEditor &
> >
> > No, it wouldn't work because bash will look in /usr/bin for a
> > command "gedit filename.ext" which doesn't exist. You would need
> > the eval command here but you might as well write it this way:
>
> Did you try before answering ? It works.


Sorry, yes, it does work if I try it. And no, I didn't try it before.


Nils

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-01-2009, 12:46 PM
Ray Parrish
 
Default Executing a command named in a variable

Avi Greenbury wrote:
> Ray Parrish wrote:
>
>
>> Hello,
>>
>> I'm thinking of a way to set a default external editor in a bash
>> program I am writing, and need to know if it is possible to execute a
>> command named in a variable that gets set by retrieving the command
>> line for the external editor's command line from a configuration file.
>>
>> Would the following work?
>>
>> # set variable to command line
>> ExecuteEditor="/usr/bin/gedit filename.ext"
>> # execute external command.
>> $ExecuteEditor &
>>
>
> Yes, assuming you mean bash.
>
> Did you try it? It's not something that's particularly dangerous to try.
>
> It's worth checking for the existence of the $EDITOR environment
> variable, first, as this is where the user would be expected to have
> declared their preference for vim^H^H^H their favourite text editor.
>
>
>
> --
> Avi Greenbury
> http://aviswebsite.co.uk
> http://aviswebsite.co.uk/asking-questions
>
Hello,

No, I didn't try it, but a couple of others here on the list say they
have, and I'll believe them. However I like your idea of checking for
the environment variable. Thank you for the valuable tip. 8-)

Later, Ray Parrish

--
The Future of Technology.
http://www.rayslinks.com/The%20Future%20of%20Technology.html
Ray's Links, a variety of links to usefull things, and articles by Ray.
http://www.rayslinks.com
Writings of "The" Schizophrenic, what it's like to be a schizo, and other
things, including my poetry.
http://www.writingsoftheschizophrenic.com



--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-01-2009, 11:37 PM
NoOp
 
Default Executing a command named in a variable

On 12/01/2009 01:52 AM, Ray Parrish wrote:
> Hello,
>
> I'm thinking of a way to set a default external editor in a bash program
> I am writing, and need to know if it is possible to execute a command
> named in a variable that gets set by retrieving the command line for the
> external editor's command line from a configuration file.
>
> Would the following work?
>
> # set variable to command line
> ExecuteEditor="/usr/bin/gedit filename.ext"
> # execute external command.
> $ExecuteEditor &
>
> If this does not work, is there any other way to retireve the command
> line of an external command and run it?
>
> Thanks, Ray Parrish
>

Again, I think that all of these requests for bash/script/etc are
educational (to some). But again, how do they relate to this list?

This list is for ubuntu technical support; your posts are for
bash/script/command line/programming support and have nothing to do with
this list. Perhaps you could find another list to ask these questions?




--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-01-2009, 11:44 PM
Alan McKay
 
Default Executing a command named in a variable

On Tue, Dec 1, 2009 at 7:37 PM, NoOp <glgxg@sbcglobal.net> wrote:
> Again, I think that all of these requests for bash/script/etc are
> educational (to some). But again, how do they relate to this list?
>
> This list is for ubuntu technical support; your posts are for
> bash/script/command line/programming support and have nothing to do with
> this list. Perhaps you could find another list to ask these questions?

Are you an official member of the Ubuntu team?

If so, they sure could use a better spokesperson.



--
“Don't eat anything you've ever seen advertised on TV”
- Michael Pollan, author of "In Defense of Food"

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-01-2009, 11:52 PM
John Abbott
 
Default Executing a command named in a variable

On Tue, 2009-12-01 at 16:37 -0800, NoOp wrote:




Again, I think that all of these requests for bash/script/etc are
educational (to some). But again, how do they relate to this list?

This list is for ubuntu technical support; your posts are for
bash/script/command line/programming support and have nothing to do with
this list. Perhaps you could find another list to ask these questions?




If command line isn't considered Ubuntu Linux I guess talking about 3rd party applications must fill the bill.



I'll be unsubscribing -** And NoOp :* Bah Humbug!!


--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 

Thread Tools




All times are GMT. The time now is 09:55 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org