View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

IRAF ALIAS

sapna wrote on Feb 23, 2016


hello all,

I have made some alias for few commands in my shell .bashrc file( eg. alias c='clear', alias l='ls' etc) when I open xgterm window and in ecl prompt when i type

cl> !l

I get error /bin/bash: l: command not found.

Is there any way I can use shell alias inside my ecl prompt ????/

Mike Fitzpatrick wrote on Feb 23, 2016


It can be done, but not easily.

The CL allows for two OS escape commands: a single '!' escape will execute the command using whatever your default shell is or the shell named by your SHELL environment variable, a double '!!' will force the use of /bin/sh. The libc execl() function is used to spawn the command (in os$zoscmd.c) but since the $SHELL value isn't parsed for multiple arguments you can't simply define $SHELL to include a '-l' or '-i' to force it to read startup files and pickup the alias. Instead, you need to create a script something like


    #!/bin/bash -i

    /bin/bash -i -c $@
 


and call it say 'myshell' in your home directory and make it executable. Then do an "export SHELL=/home/fitz/myshell" before logging into the CL. The two "-i" flags are required in the script (for different reasons) but will force your .bashrc file to be read and the commandline arguments will be executed.

If you have an alias such as "alias foo=/bin/ls" in your .bashrc file the IRAF escape command "!foo" should then work. Note however there are often IRAF equivalents for many commands or in some cases it may be better to write your own CL script do to what you want.


sapna wrote on Feb 26, 2016


my alias:

alias xgs='xgterm -sb &'

In my bashrc file I did: export SHELL=/home/cs/myshell

myshell file:

#!/bin/bash -i

/bin/bash -i -c $@ I

I made this file executable as suggested by you.

But funny thing is happening that when I am typing xgs on my terminal xgterm window is appearing for 1 sec and it is just after that getting disappeared. I don't know what went wrong when I am removing this export part from my bashrc file xgterm window is opening on typing xgs only.

For the very first time when I added myshell my xgterm window got opened and all my remaining aliases where running in ecl prompt.

But after then xgterm is not opening.

Last post on Feb 26, 2016