2

My source command in the CShell goes like this :

source /directory/of/script/script.csh

The script.csh executes and in between, waits for my password to confirm the identity.

I am tired of typing the password everytime I have to source. So, since my password is constant, I was thinking of creating an alias which goes like this :

alias <alias name> 'source /directory/of/script/script.csh; <my password>'

The only catch is that, it is not taking in my password because, technically, my password is executed after the complete execution of the source.

How do I go about it?

If anyone needs any further info, I am happy to provide.


EDIT: The original script.csh CAN NOT be modified to exclude the password because, I am not authorised to make such changes.


EDIT (2) : The actual need is to pass on a value (a particular number, depending on what I am about to do after this) to the shell script script.csh while it is being executed, without user intervention.

I used the word 'password' because, it was easier to explain using that example as authentication is some thing that is usually asked repeatedly in between a process, every time one tries something, and the execution does not proceed without it, or stops if a wrong input is given.. And, my case is synonymous : I have to give an input for the script to proceed, and it halts if a wrong input is given.

8
  • 1
    Whoa! One that isn't going to work, and 2 don't do that. What's in the script.csh that needs your password each time?
    – slm
    Feb 5, 2014 at 4:58
  • script.csh is created by my IT admin, and has a lot of other functions. What I want to avoid is, typing my password everytime it pauses.. So, why is it not going to work? Why does source command take any arguments?
    – newbie
    Feb 5, 2014 at 5:01
  • What are you needing to resource out of this script.csh file everytime? Can you not create another file with just the setting you're changing, and resource that instead?
    – slm
    Feb 5, 2014 at 5:02
  • 4
    You probably need to use something like expect, but putting your password in plaintext in a login script is really not a good idea Feb 5, 2014 at 5:08
  • 1
    I hope you understand our line of questioning and apprehension, since most of us are admins of one sort or another and what you're asking us is "how do I go around X". I know I'd be mad if some other admin told my users how to circumvent something like this. Have you tried to discuss it w/ your admins to understand why this is in place to begin with? Seems like they should be trying to help you be efficient too.
    – slm
    Feb 5, 2014 at 5:11

1 Answer 1

0

RESOLVED : Thanks to this answer. I was able to pipe in my input to the source command thereby removing my intervention. I created a script to do some of the other things I wanted to do, and added it to the alias, and is working fine.

The command which worked was:

echo $arg1 | source /directory/of/script/script.csh | tee /log-file/destination/filename.dat

the tee command allowed me to capture the output of the source command into a .dat file. And for the benefit of others looking for a similar solution, another quick idea : one can pipe in any number of arguments to the command, but take care to pass it in the order in which it will be invoked / asked.

Also, I agree to what others pointed out already, it would not be a good idea to pipe in your credentials like this and script to avoid re-typing every time.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .