Using alias to create subshell and work in it


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Using alias to create subshell and work in it
# 1  
Old 06-22-2012
Using alias to create subshell and work in it

using kerberos to access remote server. first I execute
Code:
kshell

to create subshell and then
Code:
kinit username@domain

in that subshell. After that it prompts to enter password.

Since I need to do this over and over, I am trying creating alias. I tried
Code:
kshell; kinit username@domain

. Did not work, comes back to parent shell and if I type exit, it prompts for password.

Will appreciate any suggestions to create a smart alias in bashrc.
# 2  
Old 06-22-2012
You're trying to create an alias that types in your password for you?

Authentication systems read direct from the terminal, that's not going to work.
# 3  
Old 06-23-2012
If you just want to launch the kinit command using kshell, omit the semicolon:
Code:
alias kk='kshell kinit username@domain'

Better yet with full path, like
Code:
/bin/kshell kinit username@domain

Or you can wrap it in a script:
Code:
#!/bin/kshell
kinit username@domain

make it executable and copy it somewhere in your $PATH/
# 4  
Old 06-25-2012
I am not trying to enter password through alias, just trying to combine kshell and kinit commands.
Thanks for reply mirni, your proposed solution did not work for me. It gives no error but returns to parent shell and does not ask for password.
# 5  
Old 06-25-2012
Quote:
Thanks for reply mirni, your proposed solution did not work for me. It gives no error but returns to parent shell and does not ask for password.
Which solution? mirni gave several.

The problem is, you are asking for kshell to read from two different things -- want it to run a noninteractive shell to do something in, then suddenly become interactive and accept input from a user.

Putting a semicolon afterwards doesn't tell it to feed that command into kshell. It tells it to feed it into your shell.

Depending on how kshell works, perhaps something like this:
Code:
kshell kinit username@domain ';' exec /bin/sh

should execute the command, then run an interactive shell after that... The quotes around the semicolon so that kshell gets fed the whole thing instead of your local shell breaking it into two statements.
# 6  
Old 06-26-2012
corona and mirni, both of yours' suggestions did not work so far

The usual process:
Code:
$ kshell
$ kinit username@domain
Password for username@domain:


Code:
$ kshell kinit username@domain
$

$ kshell kinit username@domain ';' exec /bin/sh
$

writing a script as suggested by mirni also did not work. I am trying to create the alias as I have to do this procedure several times each day.

Thanks
# 7  
Old 06-26-2012
Quote:
Originally Posted by analyst
corona and mirni, both of yours' suggestions did not work so far
In what way did they "not work"? More information, please.

Also please tell me more about this 'kshell'. Whether what you want is even possible or not depends on how it works, and I can't seem to find any consistent information on it.

Perhaps a script like this:
Code:
#!/bin/kshell
kinit username@domain
exec /bin/sh

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Alias does not work with bash profile

Hi, Below is what i have in my profile: alias wldm='cd /opt/app/wls' If i use bash or ksh shell this alias does not work. What should be done for this alias to work with all these simultaneously -> No Shell, bash shell, and ksh shell (14 Replies)
Discussion started by: mohtashims
14 Replies

2. UNIX for Dummies Questions & Answers

Create alias files (not alias commands)

If one: $ find -name 'some expression' -type f > newfile and then subsequently wants to create an alias file from each pathname the find command retrieved and the > placed within 'newfile', how would one do this? Ideally, the newly created alias files would all be in one directory. I am... (3 Replies)
Discussion started by: Alexander4444
3 Replies

3. Shell Programming and Scripting

Create an alias

I want to create an alias cpage4 and create a postscript file For example I want to call cpage4 file.f which creates the file file.ps I have written like this but don't know how to continue alias cpage4 '/usr/bin/mpage -m40 -4AHP- \!* (6 Replies)
Discussion started by: kristinu
6 Replies

4. UNIX for Dummies Questions & Answers

A very simple script, but alias won't work

I am new to unix and therefore I did a lot of reading before posting. So please, if this has been answered before, forgive me for re-posting and point me to the right place for the answer. I have spent many hours searching the net and read over 50 posts in this forum and even tried a few thing but... (20 Replies)
Discussion started by: sssccc
20 Replies

5. Shell Programming and Scripting

Bash alias for complicated ls command does not work.

I'm trying to set up an alias in .bash_aliases to show just the filenames of the files in a directory, which the following command will do: ls -l | grep ^- | awk '{print $NF}' kjb.zip ap.zip tor.zip However when I set up the following alias in .bash_aliases: alias lf="ls -l | grep ^- |... (16 Replies)
Discussion started by: gencon
16 Replies

6. Shell Programming and Scripting

Global alias does not work in shell script

Hi Linux Set up - alias ls='ls -l' Then run script #! /bin/ksh sub() { ls } sub Is there any way to get it working. I don't want to define alias inside of the program Thank you (2 Replies)
Discussion started by: zam
2 Replies

7. Shell Programming and Scripting

Need to create an ALIAS....

Hi GUYS, I need to create an alias for the the connect statement. I want to replace "CONNECT TO DBNAME" to "CONNECT TO DBNAME user USERID using PASSWORD" I thought i will add an alias in the .profile. But its not working. May be because i am trying to create it for 3 words instead of one... (2 Replies)
Discussion started by: mac4rfree
2 Replies

8. Shell Programming and Scripting

alias doesn't work

Hi I have put alias ll='ls -la' in .profile file but it doesn't work. On hand it works it looks like the .profile file is not beeing read. How to check whitch file is loaded? ,profile? .bash_profile? My system: SunOS mion 5.10 Generic Shell: /bin/pfksh Thanks (2 Replies)
Discussion started by: miojamo
2 Replies

9. UNIX for Dummies Questions & Answers

How to create a alias with an argument

If I want to create an alias called "cdr", and this alias need an argument (for example arg1)followed by "cdr", the result should go to the directory like "/home/ting/arg1/report/logs", the command should look like below, alias cdr arg1 "cd /home/ting/\!$1/report/logs" (not working)::( ... (1 Reply)
Discussion started by: ting123
1 Replies

10. Programming

Create an alias

I want to create an alias that will grep the passwd file for the logged in persons username and then it will return the password file entry. I want to pipe the whoami info to the grep command. I have created the following: % alias whopw grep... (1 Reply)
Discussion started by: mozark
1 Replies
Login or Register to Ask a Question