Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-22-2012
Registered User
 
Join Date: Jul 2011
Posts: 20
Thanks: 3
Thanked 1 Time in 1 Post
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.
Sponsored Links
    #2  
Old 06-22-2012
Mead Rotor
 
Join Date: Aug 2005
Location: Saskatchewan
Posts: 16,383
Thanks: 491
Thanked 2,535 Times in 2,418 Posts
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.
Sponsored Links
    #3  
Old 06-23-2012
Registered User
 
Join Date: Mar 2011
Posts: 679
Thanks: 47
Thanked 176 Times in 169 Posts
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
Registered User
 
Join Date: Jul 2011
Posts: 20
Thanks: 3
Thanked 1 Time in 1 Post
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.
Sponsored Links
    #5  
Old 06-25-2012
Mead Rotor
 
Join Date: Aug 2005
Location: Saskatchewan
Posts: 16,383
Thanks: 491
Thanked 2,535 Times in 2,418 Posts
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.
Sponsored Links
    #6  
Old 06-26-2012
Registered User
 
Join Date: Jul 2011
Posts: 20
Thanks: 3
Thanked 1 Time in 1 Post
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
Sponsored Links
    #7  
Old 06-26-2012
Mead Rotor
 
Join Date: Aug 2005
Location: Saskatchewan
Posts: 16,383
Thanks: 491
Thanked 2,535 Times in 2,418 Posts
Quote:
Originally Posted by analyst View Post
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

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Create alias files (not alias commands) Alexander4444 UNIX for Dummies Questions & Answers 3 04-16-2012 10:57 AM
A very simple script, but alias won't work sssccc UNIX for Dummies Questions & Answers 20 05-22-2010 07:49 AM
Bash alias for complicated ls command does not work. gencon Shell Programming and Scripting 16 03-16-2010 04:26 PM
Global alias does not work in shell script zam Shell Programming and Scripting 2 08-17-2009 03:04 AM
alias doesn't work miojamo Shell Programming and Scripting 2 03-06-2009 03:53 AM



All times are GMT -4. The time now is 03:31 PM.