How do I pass arguments to the "source" command?


newbie

My sourcecommand in CShell looks like this:

source /directory/of/script/script.csh

Between script.cshexecution and my password awaits confirmation of identity.

I'm tired of having to enter my password every time source. So since my password is constant, I'm thinking of creating an alias like this:

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

The only problem is that it didn't use my password because technically it my passwordwas executed after the full execution source.

what should I do?

If anyone needs any further information, I'll be happy to provide it.


EDIT: The original password script.cshcannot be modified to an excluded password because I don't have permission to make such changes.


Edit (2): The actual need is to pass a value (a specific number, depending on what I'm going to do after this) to the shell script when the script is script.cshexecuted , without user intervention.

I use the word "password" because it's easier to use e.g. authentication to explain something, usually a process between asking repeatedly , each time one tries something, and executes it instead of continuing without it, or stopping if given An incorrect input was made. .and, my case is synonymous: I have to make input for the script, and it will stop if wrong input is given.

newbie

SOLVED: Thanks for this answer . I was able to feed the input into the source command, eliminating the intervention. I created a script to do some other things I want to do and added it to the alias and it works fine.

The command that worked was:

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

This teecommand allows me to capture the output of the source command into a .datfile. Another quick thought for the benefit of others looking for a similar solution: you can pipe any number of arguments to a command, but be careful about the order in which it's called/asked.

Also, I agree with what others have already pointed out, it's not a good idea to enter credentials and scripts like this to avoid retyping each time.

Related


How do I pass arguments to the "source" command?

newbie My sourcecommand in CShell looks like this: source /directory/of/script/script.csh Between script.cshexecution and my password awaits confirmation of identity. I'm tired of having to enter my password every time source. So since my password is constant

How do I pass arguments to a command in a PowerShell script?

Hendre I want to execute a Java command: java -jar cli.jar <arg> <arg>from inside a PowerShell script. How do I pass command line arguments passed to a PowerShell script to a Java command inside the script? clumsy puffin If you want to pass command line argume

How do I pass arguments to a command in a PowerShell script?

Hendre I want to execute a Java command: java -jar cli.jar <arg> <arg>from inside a PowerShell script. How do I pass command line arguments passed to a PowerShell script to a Java command inside the script? clumsy puffin If you want to pass command line argume

How do I pass arguments to a command in a PowerShell script?

Hendre I want to execute a Java command: java -jar cli.jar <arg> <arg>from inside a PowerShell script. How do I pass command line arguments passed to a PowerShell script to a Java command inside the script? clumsy puffin If you want to pass command line argume

How to pass arguments when calling `source` command

shot I need to run a command sourcefrom a c++ program and pass a filename and some arguments. Is it possible? I want to use them in scripts like command line arguments (with argc, argv0, ...). http://www.astro.princeton.edu/~rhl/Tcl-Tk_docs/tcl/source.n.html d

How to pass arguments when calling `source` command

shot I need to run a command sourcefrom a c++ program and pass a filename and some arguments. is it possible that? I want to use them in scripts like command line arguments (with argc, argv0, ...). http://www.astro.princeton.edu/~rhl/Tcl-Tk_docs/tcl/source.n.h

How do I feed a command with arguments to Bash?

d3pd I need to type a UTC timestamp (like "2017-01-25T1422Z") very regularly, so I set it as a shortcut key in Ubuntu ( Ctrl+ Shift+ d) . Specifically, the custom shortcut keys are set to the following commands: bash /home/user/scripts/type_time_UTC.sh The sc

How do I feed a command with arguments to Bash?

d3pd I need to type a UTC timestamp (like "2017-01-25T1422Z") very regularly, so I set it as a shortcut key in Ubuntu ( Ctrl+ Shift+ d) . Specifically, the custom shortcut keys are set to the following commands: bash /home/user/scripts/type_time_UTC.sh The sc