问题描述:

The -V option with qusb only importing the environment variable but not the alias from .bashrc . For example

### in .bashrc

alias ll='ls -ltr'

alias la='ls -A'

export PYTHONPATH=/local/python_other:$PYTHONPATH

and the qsub script is

#!/bin/sh

#$ -V

echo $PYTHONPATH

ls

ll

la

In this case echo $PYTHONPATH and ls works fine but ll and la gives error ll: command not found .

So how to import the alias commands in qsub ?

OR is there any better alternative to alias so that commands (ll or la) behave like ls and can be easily imported

网友答案:

Aliases are intended to be command-line conveniences. They are not well-suited for use in scripting. For most purposes, you should use functions. Functions can be exported to child Bash scripts, but not likely to other environments.

That said, you can try explicitly sourcing your ~/.bashrc in your qsub script.

. $HOME/.bashrc

or

source $HOME/.bashrc

I don't know which of these is supported by qsub.

网友答案:

~/.bashrc is not interpreted if you run a script not in an interactive mode. You must switch the interactive mode on

#!/bin/bash -i

or better just import ~/.bashrc explicitly at the beginning of the script:

. ~/.bashrc
相关阅读:
Top