symbolic links, aliases, cls clear

Keith Thompson kst-u at mib.org
Wed Mar 29 18:03:30 EST 2006


"mp" <mailpitches at email.com> writes:
> i have a python program which attempts to call 'cls' but fails:
>
> sh: line 1: cls: command not found
>
> i tried creating an alias from cls to clear in .profile, .cshrc, and
> /etc/profile, but none of these options seem to work.
>
> my conclusion is that a python program that is executing does not use
> the shell (because it does not recognize shell aliases). is this
> correct?

Yes.

> should i use a symbolic link? if so, where should i place it?

You could, but I don't think it's the best solution.

> what is the difference between aliases and symbolic links?

Aliases exist only in a shell.  Symbolic links exist in the file
system.

> if i execute a command like 'clear' to clear the screen, where does the
> shell look to find the command 'clear'?

Generally it searches $PATH for an executable file called "clear".

I don't know Python very well (note the cross-post), but if it
provides a way to detect which operating system you're running on, you
could execute "cls" if you're on Windows, or "clear" if you're on a
Unix-like system.  Or there might be some Python library with a
clear-screen function.

Are you sure you want to clear the screen?  If I run your program and
it clears my screen for me, it could be erasing significant
information.  If you want complete control over the screen, you should
probably use something like curses or ncurses (there may be a Python
interface to it).

-- 
Keith Thompson (The_Other_Keith) kst-u at mib.org  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst>
We must do something.  This is something.  Therefore, we must do this.



More information about the Python-list mailing list