Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am running command in a bash shell as follows:

/usr/bin/ntlm_auth --request-nt-key --domain=TEST.DOMAIN --username=Administrator --password=mypassword

Although I would like to trim the last 6 characters from the end of the line (before processing) - but I would like to be able to do this within the shell and not rely on a script

share|improve this question
    
Strange question, doesn't make any sense to me. Characters are deleted from the end of line by pressing backspace six times. Do you want a readline key binding which does this? –  Hauke Laging Apr 17 '13 at 10:01
    
@Hauke Laging Well the command is being executed by a program, but the password being input into the command is too long and hence needs to be trimmed –  Mike Apr 17 '13 at 10:04
2  
Now it does not make sense to me either :/ –  dawud Apr 17 '13 at 10:07
    
How does the command get into the shell? –  Hauke Laging Apr 17 '13 at 10:21
    
Could you elaborate a bit more? What is it you are trying to do here? –  Krist van Besien Apr 17 '13 at 10:24

1 Answer 1

Use a function:

foo (){
  /usr/bin/ntlm_auth --request-nt-key --domain=TEST.DOMAIN --username=Administrator --password="${1%??????}"
}

Call it:

foo m7s5p3rs3cr3tpXss

Of course input sanitizing (not shown here) applies.

share|improve this answer
2  
How exactly does this trim the last six characters from the password? –  MadHatter Apr 17 '13 at 10:09
    
@MadHatter I made an edit to correct that. –  Hauke Laging Apr 17 '13 at 10:28
    
@MadHatter You are right. I'm not answering the question, but rather trying to guess what is being asked. I'm removing this answer. –  dawud Apr 17 '13 at 11:03
    
@HaukeLaging Indeed, that should do it, but I'm not sure anymore about the way the OP wants this to happen :| –  dawud Apr 17 '13 at 11:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.