> In the end I'd like to be able to run a custom interpreter and just feed
> it one command and a directory. The end result in the kickstart
> something like this:
>
> %post --interpreter #!/usr/bin/myinterpreter
> DROP /tmp/directory
> DROP /tmp/directory2
>
> How would I setup the interpreter to take the DROP command? I've been
> reading and searching all day but I haven't found anything close to what
> I'm doing. I realize that using custom commands in this case is overkill
> but in the end is used to make the users life easier. If anyone can
> point me to some documentation I would be more than grateful.
I'm not sure I understand what you're doing, but maybe you'll find the
following somewhat useful:
>>> import code
>>> class MyInterpreter(code.InteractiveConsole):
... def raw_input(self, prompt=None):
... # override input function
... while 1:
... text = raw_input(prompt)
... if text.startswith("DROP"):
... # deal with custom command
... print "CUSTOM DROP COMMAND", text
... else:
... return text
...
>>> i = MyInterpreter()
>>> i.interact()
Python 2.5.2 [...]
Type "help", "copyright", "credits" or "license" for more information.
(MyInterpreter)
>>> print "hello"
hello
>>> DROP something
CUSTOM DROP COMMAND DROP something
>>> x = 10
>>> y = 20
>>> x + y
30
>>> DROP something else
CUSTOM DROP COMMAND DROP something else
>>>
</F>
> That's kinda what I'm looking for, but it can't be interactive
> as there's no way to send input during the installation.
> It should pass the DROP statements to the interpreter and the
> interpreter takes the input and runs os.rmdir()
> or something similar. This way the backend does all the
> work and the frontend
wouldn't it be easier to use a good old Unix shell for this? or just a
stock Python with some boilerplate code?
drop("/stuff")
drop("/otherstuff")
</F>
What is the problem you are trying to solve? Are you asking how to
write a shell in Python?
<pet peeve>
> How would I setup the interpreter to take the DROP command?
You wouldn't... "setup" is a noun. You might "set up" an interpreter
though.
</pet peeve>
> I've been reading and searching all day but I haven't found anything
> close to what I'm doing. I realize that using custom commands in
> this case is overkill but in the end is used to make the users life
> easier.
How so? What could be easier than "rm -rf directory"?
> If anyone can point me to some documentation I would be more than
> grateful.
I'd be happy to, but I can't imagine what sort of documentation would
help you. It sounds like what you want to do, basically, is write a
program to read commands from stdin, parse them to make sure the
syntax is right, and then execute the equivalent code in Python.
--
Derek D. Martin
http://www.pizzashack.org/
GPG Key ID: 0x81CFE75D
> In the end I'd like to be able to run a custom interpreter and just feed it
> one command and a directory. The end result in the kickstart something like
> this:
>
> %post --interpreter #!/usr/bin/myinterpreter
> DROP /tmp/directory
> DROP /tmp/directory2
You don't need a custom interpreter to do this. Just use shell commands:
%post
rm -rf /tmp/directory
rm -rf /tmp/directory2
will do the trick (if I am understanding correctly).
--
Mitko Haralanov mi...@qlogic.com
Senior Software Engineer 650.934.8064
HSG InfiniBand Engineering http://www.qlogic.com
==========================================
Fry: Lucy Liu-bot, if I don't survive the corn, I want you to know
that I love you as much as a man can love a computerized image of a
gorgeous celebrity, which it turns out is a lot.
> How so? What could be easier than "rm -rf directory"?
C:\>rm -rf directory
Illegal command: rm.
Hm. ;-)
Ciao,
Marc 'BlackJack' Rintsch
>> How so? What could be easier than "rm -rf directory"?
>
> C:\>rm -rf directory
> Illegal command: rm.
>
> Hm. ;-)
does CentOS/Fedora run Windows these days?
</F>
http://docs.python.org/lib/module-cmd.html
On Wed, Aug 20, 2008 at 9:19 PM, joey boggs <jbo...@gmail.com> wrote:
> I've got a hopefully simple question, maybe I'm just not searching for the
> right information.
>
> I'm working on a project that is using kickstarts to build Fedora/CentOS
> variant machines. Within the kickstart in the post section we will be
> performing disk space reductions by removing any unnecessary directories on
> the machine.
>
> In the end I'd like to be able to run a custom interpreter and just feed it
> one command and a directory. The end result in the kickstart something like
> this:
>
> %post --interpreter #!/usr/bin/myinterpreter
> DROP /tmp/directory
> DROP /tmp/directory2
>
>
> How would I setup the interpreter to take the DROP command? I've been
> reading and searching all day but I haven't found anything close to what I'm
> doing. I realize that using custom commands in this case is overkill but in
> the end is used to make the users life easier. If anyone can point me to
> some documentation I would be more than grateful.
>
> Thanks,
> Joey
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://www.xing.com/profile/Martin_Marcher
You are not free to read this message,
by doing so, you have violated my licence
and are required to urinate publicly. Thank you.
OP may also would like to hack his own language using EasyExtend:
http://www.fiber-space.de/EasyExtend/doc/EE.html
Most likely an overkill.
--
Jan Wicijowski
Yeah, except the application specified by the OP is to remove
directories during a kickstart install of Linux... so your comment is
worthless.