How to run a new shell with copy of current shell declarations?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to run a new shell with copy of current shell declarations?
# 8  
Old 05-31-2008
Quote:
How to run another shell and have all current shell dectaration copied to that new shell?

I would like to have available all current declarations in a new shell. That are functions, aliases, variables.
Possible but not easily done. Think about it, opens up all sorts of security issues.

BTW, most test suites use a combination of TCL and expect to test shell scripts.
# 9  
Old 05-31-2008
How about:
Code:
$ declare > my_declarations
$ bash
$ source my_declarations

I'm not sure that's what you're looking for, but it might work... dunno

*EDIT:
no... don't even bother... declare doesn't store alias declarations

Last edited by jimcanoa; 05-31-2008 at 12:21 PM..
# 10  
Old 06-02-2008
Works for me, but I guess you will have to set -a before you declare the ones you want exported.

Code:
vnix$ PS1='nst> '
nst> set -a
nst> fnord=foo
nst> foo () { echo foo; }
nst> alias bar='echo bar'
nst> bash
vnix$ echo "$fnord"
foo
vnix$ foo
foo
vnix$ bar
bash: bar: command not found
vnix$ exit
nst> exit

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies

2. Shell Programming and Scripting

Converting shell to Perl I run into shell built in function trap and need alternative in Perl

I am working on converting shell to Perl script. In shell we have built in function trap Do you know alternative in Perl or actually we don't need it? Thanks for contribution (3 Replies)
Discussion started by: digioleg54
3 Replies

3. Shell Programming and Scripting

Current shell session hungs when run another binary

Hi, I am on AIX 7.1 and when I try to login to my account and sudo to other generic account (mqm user) my ssh session just hungs. ================== $ id uid=16150(sxp) gid=179(rax) groups=1179(raxs) $ $ $ sudo su - mqm Password: -------- Changed username to: mqm -------- .... (1 Reply)
Discussion started by: bdpl
1 Replies

4. UNIX Desktop Questions & Answers

command to run another shell on top of your default shell?

Can someone point me to the right command to to run another shell on top of your default shell? Thanks PS If admin sees this It is not home work. I am old man who wants to learn unix in my spare time. I CURRENTLY DO NOT GO SCHOOL, COLLEGE OR UNIVERSITY. (2 Replies)
Discussion started by: Bill Thompson
2 Replies

5. Shell Programming and Scripting

[How To?] Run shell script and get output into another shell.

Hi guys, I have a simple question, I want to store the output of the following command: As you can see it is running all the time, and we get a new line every 3sec. I just want to store these new lines into a single variable, so I can use it into a script. To clear the screen, and... (4 Replies)
Discussion started by: Thireus
4 Replies

6. Shell Programming and Scripting

How to run cmds after changing to a new env (shell) in a shell script

Hi, I am using HP-UNIX. I have a requirement as below I have to change env twice like: cadenv <env> cadenv <env> ccm start -d /dbpath ccm tar -xvf *.tar ccm rcv .... mv *.tar BACKUP but after I do the first cadenv <env> , I am unable to execute any of the later commands . ... (6 Replies)
Discussion started by: charlei
6 Replies

7. Shell Programming and Scripting

Help need to make a shell script run for ffmpeg vhook watermaking in shell

i have a small problem getting a batxh shell script to run in shell this is the code the problem seems to be centered around the ffmpeg command, something maybe to do with the ' ' wrapping around the vhook part command this is a strange problem , if i take the ffmpeg command and... (1 Reply)
Discussion started by: wingchun22
1 Replies

8. Shell Programming and Scripting

Run a C Shell using only Bash shell

Hi, I have only bash on my system. And I want to run a C shell... Is there a way for that? (3 Replies)
Discussion started by: HSN
3 Replies

9. Shell Programming and Scripting

How to run unix commands in a new shell inside a shell script?

Hi , I am having one situation in which I need to run some simple unix commands after doing "chroot" command in a shell script. Which in turn creates a new shell. So scenario is that - I need to have one shell script which is ran as a part of crontab - in this shell script I need to do a... (2 Replies)
Discussion started by: hkapil
2 Replies

10. UNIX for Dummies Questions & Answers

How to run a command in shell 'A' from shell 'B'

Hello all.. I just want to login(ssh) to another system and run 'poweroff' command. This must be accomplished via a shell script($sh Myhalt host_name) and not from my bash!! Any idea??? :rolleyes: (1 Reply)
Discussion started by: rakabarp
1 Replies
Login or Register to Ask a Question