Ok I asked something similar earlier with no response, so maybe I didn't word it correctly. I'm new at this, so thank you for your help.
Here's what I have right now.
----------------------------
Code:
> cat MySourceFile
#!/bin/csh
echo "Please Enter Value For My_Env_Var:"
set answer = $<
setenv My_Env_Var $answer
echo "My_Env_Var in source file is set to $My_Env_Var"
> cat MyInputFile.txt
Hello_World
> cat MyScript.csh
#!/bin/csh
source MySourceFile < MyInputFile.txt
echo "My_Env_Var in script file is set to $My_Env_Var"
> MyScript.csh
Please Enter Value For My_Env_Var:
----------------------------
When I run MyScript.csh it's waiting for input from the keyboard, even though I tried to redirect the contents of MyInputFile.txt to use as input.
How do I use the contents of MyInputFile.txt as the input for the source of MySourceFile?
If this can't be done using a .txt file, is there another way it can be done?
Thank you for any help you can provide
Last edited by pludi; 02-16-2010 at 11:23 AM..
Reason: code tags, please...
echo "Please Enter Value For My_Env_Var:"
set answer = $<
setenv My_Env_Var $answer
echo "My_Env_Var in source file is set to $My_Env_Var"
> cat MyInputFile.txt
Hello_World
> cat MyScript.csh
#!/bin/csh
source MySourceFile < MyInputFile.txt
echo "My_Env_Var in script file is set to $My_Env_Var"
> MyScript.csh
Please Enter Value For My_Env_Var:
----------------------------
When I run MyScript.csh it's waiting for input from the keyboard, even though I tried to redirect the contents of MyInputFile.txt to use as input.
How do I use the contents of MyInputFile.txt as the input for the source of MySourceFile?
If this can't be done using a .txt file, is there another way it can be done?
Use the standard Unix shell, not csh.
Code:
#!/bin/sh
read My_Env_Var
echo "My_Env_Var in source file is set to $My_Env_Var"
Using the C Shell, I'm building a script that will compute simple mathematical computations (addition, subtraction, multiplication, division). The user will enter two integers (operands) on the command line separated by the operation (operator) they wish to perform.
Example of the command line... (7 Replies)
Hello all. I suspect this will be a simple case for an experienced csh scripter, but google is getting me nowhere on this one.
I'm trying to get someone else's set of scripts to work for me, and it's choking when the following script gets called:
#! /bin/csh
if (x$1 == x) then
echo ' you... (1 Reply)
Hey all,
I've only just started using UNIX coding on my Masters project, so am still learning!! The script I've been writing is literally just for me to get used to writing it and seeing what I can do with some data I've been given.
I'm trying to write a script, where the penultimate line... (2 Replies)
Hey I am brand new to this forum and scripting.
I have several documents (1000+) all formated exactly the same. Each document contains 97 lines. I want to pull 3 lines from the documents to populate a file. These 3 lines are line number 9, 24, and 58.
Ok my questions: Instead of using... (3 Replies)
I have an extraordinary problem with a csh script.....(feel free to berate the use of this but I'm modifying an existing bunch of them)
Anyway, I have a master csh script which in turn calls a second csh script. This second csh script is below. Within this second script are two compiled C++... (1 Reply)
Hi All,
I have the following script.
#!/bin/csh
#
# createDATfile.sh
#
cd /export/home/fastserv/bin
source /export/home/fastserv/bin/dbenv.sh
echo `date` >> /export/home/fastserv/bin/log.txt
echo "%INF% Starting send of current FASTSERVICE batch" >>... (4 Replies)
After I compile a C program, when I run it from a C shell script, it does not print out the results.
e.g:
myCFile.c: main(){printf("Hey");}
myCshScript: myCFile
This does not output "Hey" to the terminal window. I am not even sure if it is executed or not.
What should I do to see the... (2 Replies)