Export script to current session


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Export script to current session
# 1  
Old 10-14-2011
Question Export script to current session

Hi,

I have a script called

Code:
bash$> cat -ev setprofile.sh
alias rm='rm -i'$
$

The alias does not take effect unless i run the script as

Code:
bash$> . ./setprofile.sh

What do I have to do in-order to simply run


Code:
 
bash$> ./setprofile.sh

and do not have to put two dots for exporting to the current session.

Regards,
Mohtashim
# 2  
Old 10-14-2011
# 3  
Old 10-14-2011
It seems that your script requires to export your environment variables because it reads from the environment variables it seems there are some checks .

you can run
Code:
$ source  ./setprofile.sh

or
Code:
$ bash ./setprofile.sh

# 4  
Old 10-14-2011
The . (or source) runs it in the current environment, which you have to do if you want your alias to take affect in the parent shell.
# 5  
Old 10-14-2011
Error

So are you saying there is no way except having two "." dots ?
# 6  
Old 10-14-2011
Pretty much.

But the dots aren't related - one is a command to source a file, and the other is part of the pathname (and there's one in the basename as well! Smilie).

EDIT: Why is having two extra characters to type such an issue anyway? If it's something you do on every session, why not run it from your .profile (or whichever shell equivalent)?


Quote:
Originally Posted by h@foorsa.biz
Code:
$ bash ./setprofile.sh

Will start a subshell, so it won't change the alias in the current shell.
# 7  
Old 10-14-2011
Quote:
Originally Posted by CarloM
Pretty much.
Will start a subshell, so it won't change the alias in the current shell.
Yes I know but it will initialize the .profile again
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. 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

2. Red Hat

Current Session History

Dear All, I want to display the command related to current session in Redhat Linux 5. Below history command display all the command in ~/.bash_history file. $history My requirement is the command executed in my current session.I mean to say. Suppose after log in as root i executed ... (1 Reply)
Discussion started by: monojcool
1 Replies

3. Shell Programming and Scripting

Script for Export backup!!

Dear Team, Can you please help me to write the script for export backup. I've written some of the part and stuck in "if" condition Apprecatied if you help me. Requirement:- Export backup completion sent the email if it is success (sent backup success email)or if fails (sent backup fails... (9 Replies)
Discussion started by: Mohammed Fareed
9 Replies

4. Shell Programming and Scripting

running a bash script even after logging out from the current session

HI , I have a simple script that moves files from one folder to another folder, I have already done the open-ssh server settings and the script is working fine and is able to transfer the files from one folder to another but right now I myself execute this script by using my creditianls to... (4 Replies)
Discussion started by: nks342
4 Replies

5. Solaris

Difference between the desktop session and console session

what is the difference between desktop session and console session in solaris as i am wondering we use option -text for the former and -nowin for the later (1 Reply)
Discussion started by: kishanreddy
1 Replies

6. Shell Programming and Scripting

Execute commands from script in current bash session

I have a file as follows: cat /etc/mxg/ssh-hostsmx.example1.com.au:2225 mx2.example2.com.au:2225 mx.example3.com.au:2225 mail.example4.com.au:2225 mail.example5.org.au:2225 mail.example6.com.au:2225I want to dynamically create aliases for quick access to these servers from bash. I wrote... (4 Replies)
Discussion started by: jelloir
4 Replies

7. Solaris

I am not able to login in gnome session and java session in Sun solaris 9& 10

I am not able to login in gnome session and java session in Sun solaris 9& 10 respectively through xmanager as a nis user, I am able to login in common desktop , but gnome session its not allowing , when I have given login credentials, its coming back to login screen, what shoul I do to allow nis... (0 Replies)
Discussion started by: durgaprasadr13
0 Replies

8. Shell Programming and Scripting

Hiding Directories on a Session by Session basis

Hi, Apologies if anyone has read my recent post on the same subject in the Linux forum, just thought actually the solution might more likely come from scripting. Essentially, I am trying to restrict access to directories based on the user's name AND their location on a session-by-session... (3 Replies)
Discussion started by: en7smb
3 Replies

9. Shell Programming and Scripting

sqlplus session being able to see unix variables session within a script

Hi there. How do I make the DB connection see the parameter variables passed to the unix script ? The code snippet below isn't working properly. sqlplus << EOF user1@db1/pass1 BEGIN PACKAGE1.perform_updates($1,$2,$3); END; EOF Thanks in advance, Abrahao. (2 Replies)
Discussion started by: 435 Gavea
2 Replies
Login or Register to Ask a Question