You are not logged in.

#1 2008-02-07 19:08:45

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,896
Website

construction of command strings in bash or python? [Solved]

I am trying to figure a way to construst a command in bash [or python]

syntax is

 command 'function string'

problem being the bit inside single quotes? I want to use different strings leaving the rest of command structure as is

something like

 command 'function ' + string

the function and string must be within single quotes

there must be a way round maybe its easier in python not sure??

MrG

Last edited by Mr Green (2008-02-08 06:49:10)


Mr Green

Offline

#2 2008-02-07 19:19:49

Gilneas
Member
From: Netherlands
Registered: 2006-10-22
Posts: 320

Re: construction of command strings in bash or python? [Solved]

Can you give an example where it goes wrong?

Is this useful:

command="ls"
function="/hom"
string="e"

eval $command \'$function$string\'

Offline

#3 2008-02-07 20:22:21

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,896
Website

Re: construction of command strings in bash or python? [Solved]

Woah!!!! eval is what I was looking for.... thought just running command and adding strings would work but no

/me hugs Gilneas

the escape \ also helps

Thanks very much I'm off to write it in python lol


Mr Green

Offline

#4 2008-02-07 21:18:08

Gilneas
Member
From: Netherlands
Registered: 2006-10-22
Posts: 320

Re: construction of command strings in bash or python? [Solved]

Bah, such sarcasm stings deeper than you think.

Offline

#5 2008-02-08 01:30:59

Gilneas
Member
From: Netherlands
Registered: 2006-10-22
Posts: 320

Re: construction of command strings in bash or python? [Solved]

Actually, who the hell do you think you are to insult someone so who tries to help you?
Your post actually has more hints of spite than sarcasm.

If this behaviour is acceptable now in these forums, I'm not staying here for another second.

Offline

#6 2008-02-08 06:09:49

gradgrind
Member
From: Germany
Registered: 2005-10-06
Posts: 921

Re: construction of command strings in bash or python? [Solved]

??? Did I miss something?

Offline

#7 2008-02-08 06:23:51

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,384
Website

Re: construction of command strings in bash or python? [Solved]

Gilneas:  I really don't think anything of offense was meant in that post.  In fact I'm not to sure where you could have got offended (the comment about going to use python after your help in bash?).  My reading of this was that Mr Green was thankful for your help.

Anyway, something obviously annoyed you enough to come back four hours later and repost here.  In fact, your second post is probably going beyond what is acceptable here.  If someone offends you or is abusive, etc, then you should use the "Report" link to contact a forum moderator about it, not retaliate with a similarly offensive post.

Last edited by Allan (2008-02-08 06:24:41)

Offline

#8 2008-02-08 06:43:46

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,896
Website

Re: construction of command strings in bash or python? [Solved]

Gilneas wrote:

Bah, such sarcasm stings deeper than you think.

Ooops did not mean anything by it, Python what I meant was use os.popen I am not much of a bash coder [hence the post!] I did search for the answer but was looking for the wrong thing such as echo $command etc..

I do apologize if I said anything to offend you, I was merely grateful for your help

MrG


Mr Green

Offline

#9 2008-02-11 11:30:28

Gilneas
Member
From: Netherlands
Registered: 2006-10-22
Posts: 320

Re: construction of command strings in bash or python? [Solved]

I thought I wasn't helpful and you were mocking stupid things in my post.

I'm sorry for the false accusations.

It happened because I had an oncoming flu and a small fever, so I wasn't thinking clearly. I also need a little break, when you're reading too many posts you spend less time understanding them.

Offline

#10 2008-02-11 19:35:57

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,896
Website

Re: construction of command strings in bash or python? [Solved]

not a problem I am [most of the time!] careful in what I post

I am using your answer in a bash script a couple of lines...

hope you are ok, yes I need a break too :-)

MrG


Mr Green

Offline

Board footer

Powered by FluxBB