Tag Info

New answers tagged

0

You could probably use git branches for this. Set your home dir up in a branch and then create another branch and configure this how you'd like for this other "profile". It would be a matter of switching branch and then you'd have effectively a different looking home dir. Then you'd probably need to source your environment or run another login shell. I ...


10

A few pieces of documentation will help to explain this. From the POSIX standards document for the shell: The following variables shall affect the execution of the shell: PS1: Each time an interactive shell is ready to read a command, the value of this variable shall be subjected to parameter expansion and written to standard error. ... ...


4

The \ character escapes the following (special) character. In this case, it escapes the $, which we usually use to dereference a variable. When the shell evaluates a variable assignment, it first expands the right-hand-side of the expression. Without the \ before $PWD, the shell expands $PWD and assigns the result to PS1. However, with the \, the shell ...


0

Jan's answer is good, the environment variable http_proxy is read by many programs, e.g. wget. You can add this export http_proxy="http://@${proxyserver}:${port}" to your ~/.bash_profile. Also yum works, but you can also specify it in /etc/yum.conf. Other programs can be configured similarly (e.g. git in ~/.gitconfig, chromium --proxy-server=host:port). ...


0

Yuo need to export the following environment variables: http_proxy='http://user:pass@PROXY_IP:PROXY_PORT/' https_proxy='http://user:pass@PROXY_IP:PROXY_PORT/' ftp_proxy='http://user:pass@PROXY_IP:PROXY_PORT/'


1

This line x=123 echo $x is evaluated in the following order: $x is exapanded to the value of x in the current shell. The value of x in the environment of the command to be executed is set to 123 The expanded command line is searched for a command, and echo is found. echo is run in an environment where x is set to 123, and $1 is set to whatever value x ...


0

Some things that may be different when a program is started via a user session rather than a startup script: The program inherits many environment variables (including PATH, HOME, …). The program inherits several file descriptors, including a terminal. Limits may be different. To run a program with a minimal environment and close the standard file ...


0

If you are using gnome graphical interface (runlevel 5), you may also try gnome-session-properties GUI for startup application. Note: This will start only after login into the gnome graphical session. If you are not using gnome you can find which startup application for your Desktop Environment.


4

You could run as root env - scriptname This will clear your environment before running the script, however, it will also keep your shell. To clear the environment and set the shell to sh, do the following: env -i /bin/sh -c scriptname This will then run the script using /bin/sh. However, this will not completely simulate the boot environment as this does ...


-1

Without more information about what your script is doing and what errors you're getting, it's difficult to give an accurate answer. That being said, it's probably possible to recreate the environment, but it will likely be very difficult, requiring to unmount or bind-mount filesystems or other such fun things. An alternative could be to create a virtual ...


0

Run sudo visudo and comment out the two lines shown below. Commenting out only env_reset does not work #Defaults env_reset Defaults mail_badpass #Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH"


1

I know it has been quite some time since you posted this question but I came across this question while I was searching for a similar question and found the answer. I believe these two articles should answer exactly what you are looking for: The first deals specifically with .bash_profile and how to handle it. The second deals with the overall setup of the ...


1

Another option, which I find easier, is to run the script with cron and tell bash to login (hence using /etc/profile.d/... environment definitions) In crontab -e file: */1 * * * * bash -l -c './cron_job.sh' */1 * * * * bash -l -c 'php -f ./cron_job.php' Any command after the source of .bash_profile will have your environment as if you logged in.


2

If it is an sh script - as in, it explicitly references #!/bin/sh - which might still be bash but would be like invoking it with --posix --no-rc --no-profile - then you can specify the ENV file with the ENV environment variable: ENV=/path/to/rcfile sh Specific variables need either to be declared on the command-line - as above for $ENV - or else with ...


3

When a script invokes another script, variables of the parent script can be exported, and then they'll be visible in the child script. Exporting functions is an obvious generalization: export the function from the parent, make it visible in the child. The environment is the only convenient way a process can pass arbitrary data to its children. The data has ...


3

I'd say it is, when bash is your /bin/sh. It's a not feature of bourne shell, and I'd bet it's not a feature of posix shell either, in fact they might want to expressly forbid it. Bash is really more of korn derivative shell, than a bourne shell, despite its name, and its the only Korn like shell that has the feature, and in my opinion it's kitchensink ...


9

It is a security risk. That's generally why you can't do it when switching to another context (remote control of a system, changing users, etc). If you have the ability to create any environment variable you want, there are any number of potential ways you can execute arbitrary code. Take $LD_PRELOAD as an example. If you have the ability to set that ...


1

You've made grep an alias for grep $GREP_OPTIONS. Don't do that: the GNU grep command itself parses the GREP_OPTIONS environment variable. If you want to put options to a command in a variable, make that variable an array, and don't export it (you can't export arrays anyway, environment variables have string values only). LS_OPTIONS=(--color=auto -q) alias ...


3

If I understand correctly, your problem is you cannot find a way to use a shell alias to interact with screen directly. Instead, you can send commands to a running screen using -X, including setenv of course, e.g.: $ screen -list There are screens on: 25216.pts-45.antiriad (Attached) $ screen -S 25216 -X setenv PRJCT 2.0 The variable is then ...



Top 50 recent answers are included