I am a bit confused how could I get an environment of a "fresh/clean" login shell, that is, the environment at that moment when user has started e.g. a new terminal/console or so.
So this is the sequence of actions I should be able to do in a single shell session:
1. open a new terminal
2. source a script which will set my environment based on some rule set
3. do my tasks in that environment
4. clean the environment from exports made in step #2
5. source a new script which will do some other environment exports based on some other rule set
6. do some stuff...
And this sequence goes on and on...
Currently, there are two ways of doing this:
a) start a new terminal each time a new environment should be taken into use
b) before sourcing, start a new shell, e.g. bash/csh/what ever, and then do the sourcing... And when done -> exit that shell to get back the login shell and then start a new shell again
The problem with both ways mentioned above is lazy users. They would like to source the script setting the environment and after finished with that, source a new environment setting script. So they don't want to start a new shell or open up a new terminal.
So this is why I'm looking for a solution how to get an environment of a clean login shell. I don't think (might be wrong here..) there is a way to do something like:
Rsh does not help either as it seems to inherit its parent's environment as well. Rlogin seems like a good option BUT how can I get the environment via rlogin without user interaction, e.g. somehow piping commands to rlogin session?
Any ideas are highly appreciated! Thanks in advance!
With "clean" I meant the environment user gets when he opens up a new terminal and types env.
The first way you suggested + sourcing /etc/profile and ~/.profile does not result to same environment compared to new terminal session. I also get warnings "WARNING: terminal is not fully functional" after that.
The second way, using awk one liner, leads to a file full of "unset $1", i.e. $1 does not get evaluated...
1. start shell_1
2. start shell_2 within shell_1, source your script_with_variable and do your stuff
3. exit shell_2 and return to shell_1
4. repeat steps 2 and 3
5. repeat steps 2 and 3
...
...
exit shell_1
You are correct, however, that is how its currently done as I mentioned in my first post:
Quote:
Currently, there are two ways of doing this:
a) start a new terminal each time a new environment should be taken into use b) before sourcing, start a new shell, e.g. bash/csh/what ever, and then do the sourcing... And when done -> exit that shell to get back the login shell and then start a new shell again
The problem is that users would like to source those environment setting scripts directly from a shell without "start a new shell - source a script - do some stuff - exit the shell - start a new shell" cycle. So they just want to "source a script - do some stuff - source a new script - do some other stuff".
So what I'm trying to accomplish here is some sort of way to make those environment setting scripts to reset the environment back to what it was at the time of login and then applying new settings. One thing to notice also is that I cannot force users to modify their .profile to save the environment at login time.
I was hoping there would be some kind of way to use rlogin (or something else giving the same result) to get a clean login shell so that I could do the following in the beginning of each script setting an environment:
* rlogin to a new shell which does not inherit the environment of parent
* at rlogin shell: env > clean_env.txt
* at script which is sourced:
** remove all environment variables and source clean_env.txt
** add some new environment variables on top of that
I know I could do this with Java or C, but I really would like to stick with shell script/perl/awk...
Sorry if I haven't been clear enough with my question
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
I need a shell script using expect to login to couple of remote servers and read "crontab -l -u <username>" & "cat /etc/rc.local" & "df -h" and able to create output into a file saved locally with hostname.crontab & hostname.rc.local & disk.status. I can supply a file as list of hostname or IP... (4 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
Hello,
I am new to this forums and this is my first "asking help" message!
i have 2 problems:
1- for unknown reasons the "source" command is not avalable in my system (UBUNTU). i can't either see it in my bin directory!
2- again for unknown reasons the "login.cl" file in the home... (0 Replies)
Hi all,
I am currently trying to tell /bin/ksh to behave like a login shell. I am invoking it from an interactive shell. In the documentation is stated, that calling it with
exec ksh -
it should behave like a login shell, work 1st on /etc/profile, ~/.profile and so on.
I tried that with... (0 Replies)
I have created a ksh shell script and used it as a login shell for a user.
</etc/passwd>
lramirev:x:111:200:Luis:/export/home/menush:/usr/local/menush/menush
My shell script is like this:
</usr/local/menush/menush>
#!/bin/ksh
#
if ]
then
. $HOME/.profile
fi
... (8 Replies)
Hi
I have installed solaris 10 on an intel machine. Logged in as root. In CDE, i open terminal session, type login alex (normal user account) and password and i get this message
No utpmx entry: you must exec "login" from lowest level "shell" :confused:
What i want is: open various... (0 Replies)