Skip to main content

All Questions

0 votes
1 answer
248 views

Is it a good idea to put "export BASH_ENV=~/.bashrc" in my .bashrc?

Let's say my Bash has some extensive ~/.bashrc customization that aids me not only in interactive use, but also in scripting (aliases, functions, variables, etc.). I would like to have this available ...
Sebastian Carlos's user avatar
1 vote
1 answer
635 views

Why not prepend user directory to PATH?

For user scripts, the usual advice is to append their directory to $PATH in one's .profile: PATH="$PATH:$HOME/.myscripts" # or .bin or whatever Apparently that is safer than prepending it: ...
Jortstek's user avatar
  • 273
1 vote
1 answer
7k views

Run a Bash Script from Python and import the exported environment variables into Python

I have the following Bash script called Test_Vars.sh #!/bin/bash #----------------------------------------------------# # Environment Variables being used in the process # #------------------------...
roachd's user avatar
  • 11
0 votes
1 answer
661 views

sudo crontab notify-send doesn't work

I have read similar posts here, here, here and here that mentioned some environment variables DISPLAY and DBUS_SESSION_BUS_ADDRESS. Setting them at the top of my user crontab enabled notify-send to ...
ripytide's user avatar
  • 103
0 votes
0 answers
3k views

Get environment variable from python script

I have bash script config.sh in which several variables are exported , and I need those variable in my python script. config.sh export VAR="YES" My approach is to source the config.sh from the ...
dejanualex's user avatar
-1 votes
2 answers
142 views

Is this allowed in an `if statement`? [closed]

# optional cropping if [ "$1" == "cropit" ]; then ITS_CROP_TIME= mkdir cropped; for i in *.mp4; do ffmpeg -i "$i" -filter:v "crop=1920:980:0:-100" cropped/"${i%.*}.mp4" rm -r *.mp4 cd ...
Anonymous's user avatar
  • 533
42 votes
3 answers
207k views

import environment variables in a bash script

I set some environment variables in a terminal, and then run my script. How can I pull in the variables in the script? I need to know their values. Simply referring to them as $MY_VAR1 doesn't work; ...
Mark's user avatar
  • 1,883
1 vote
2 answers
21k views

export PATH permanently [duplicate]

I have exported the PATH but once I switch to a different terminal or reboot Debian, $PATH is reset. Here are the steps I take: ~$ vim scripts.sh #!/bin/bash echo "Hello" I save it as mybash.sh and ...
sysadmin's user avatar
4 votes
2 answers
2k views

Is shell parent of all the processes in linux

I have been trying to understand shell scopes and environment in depth. I have been reading about how if we do export VARIABLE=VALUE it will be available in subshell. So I wanted to ask a question I ...
Ozum Safa's user avatar
  • 141
6 votes
1 answer
20k views

How to pass environment variables to a non-interactive shell (with example)?

In a sh script another sh script is started with su -l <user> -c /path/to/script.sh. As far as I understood script.sh will be run in a non-interactive shell. The official documentation tries to ...
Kalle Richter's user avatar
3 votes
0 answers
238 views

tab-expansion and “./” bash shell [closed]

Maybe someone here would be able to help me out. Have installed Ubuntu 12.04 LTS (kubuntu) on two machines. The .bashrc and .bash_profile files are identical as the file structures on each machine is ...
adeliefan's user avatar
2 votes
3 answers
1k views

What is the difference between ./script and . ./script? [duplicate]

Possible Duplicate: Using ‘.’ to execute files in bash I was trying to figure out how to export my environmental via script instead of changing my .bashrc file. I found this old useful post that ...
grebwerd's user avatar
  • 155
150 votes
11 answers
421k views

Script to change current directory (cd, pwd)

I want to run a script to simply change the current working directory: #!/bin/bash cd web/www/project But, after I run it, the current pwd remains unchanged! How can I do that?
Sony Santos's user avatar
  • 1,603
13 votes
5 answers
11k views

Last failed command in bash

The $? variable holds the exit status of last run command. Is there a variable that holds last run command itself?
Eimantas's user avatar
  • 1,516