How to run a file in a csh script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to run a file in a csh script?
# 1  
Old 06-05-2012
How to run a file in a csh script?

Hi,
I have a csh script. I want to set some variables and execute some command from a file in that script.

abc.csh
Code:
echo "primary script"

b
Code:
setenv XXX ddd
set XX 
make abc

I want to execute the commands of "b" file from abc.csh. How can i do that.

Moderator's Comments:
Mod Comment Please view this link: How to use [code]...[/code] tags

Last edited by Scrutinizer; 06-05-2012 at 03:53 AM.. Reason: code tags
# 2  
Old 06-05-2012
try this in the "abc.csh"
Code:
#!/bin/csh
echo "primary script"
/bin/csh -c /relative/PATH/b
............

# 3  
Old 06-05-2012
What is wrong with the way i am doing it?
Code:
foreach line ( "`cat b`" )
 echo $line
exec  $line
end

Whats the difference if i source the "b" file in "abc.csh" file rather then executing it.
# 4  
Old 06-05-2012
Quote:
Originally Posted by vdhingra123
What is wrong with the way i am doing it?
Code:
foreach line ( "`cat b`" )
 echo $line
exec  $line
end

Whats the difference if i source the "b" file in "abc.csh" file rather then executing it.
try with eval instead of exec
Code:
exec [-cl] [-a name] [command [arguments]]
              If command is specified, it replaces the shell.  No new process is created. 

eval [arg ...]
The args are read and concatenated together into a single command.  This command is then read  and  executed  by the  shell,

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies

2. Shell Programming and Scripting

Read variables from a text file for use in csh script

Hello, I have a text file (say, declarevars.txt) that contains multiple lines that are essentially meant to be variable declarations: set arr1 = (var1a var1b var1c) set arr2 = (var2a var2b var2c) . . . I want to be able to read this text file within a csh (sorry) script and have that... (2 Replies)
Discussion started by: arjaydj
2 Replies

3. Shell Programming and Scripting

Csh/tcsh : Check the file existance and run the script

Hi, I've to wait until a file generated and once its generated, source another script in Linux terminal. Please help me as this is very very urgent. The code should be something like if ( -e "/abc/xyz/a.txt ) source aaa.csh else sleep This should be repeated till the if... (4 Replies)
Discussion started by: kumar_eee
4 Replies

4. Shell Programming and Scripting

How to run csh environment parameters from k-shell script?

Hi Guys, I need to run an alias from a k-shell script ,for example 10204, which points to : source $ORACLE_BASE/scripts/cshrc/10204/.cshrc Meaning , I need to run in my k-shell script with the env settings parameters of the alias. How to do it in k-shell? Thanks in advance, Nir (2 Replies)
Discussion started by: nir_s
2 Replies

5. Shell Programming and Scripting

How to run a bash script in csh shell?

Hi how to execute a bash script in csh shell? Thanks (3 Replies)
Discussion started by: rubinovito
3 Replies

6. Shell Programming and Scripting

Csh script get file extension

Hi All I have a csh shell script which should check if a given file is a zip file as below: **************************************** #!/bin/csh -f if ]; then echo is a zip file else echo sorry not a zip file endif exit **************************************** ... (1 Reply)
Discussion started by: raj144
1 Replies

7. Shell Programming and Scripting

how to make your bash script run on a machine with csh and bash

hi, i have a script that runs on bash and would like to run it on a machine that has csh and bash. the default setting on that machine is csh. i dont want to change my code to run it with a csh shell. is there any way i can run the script (written in bash) on this machine? in other words is there... (3 Replies)
Discussion started by: npatwardhan
3 Replies

8. Shell Programming and Scripting

how to run ksh from csh

I'm comfortable with csh. However, i need to run a ksh script.Using exec /bin/ksh -i , I'm able to invoke ksh, but the script is not running any further. Variable QDDTS is an env setting on my csh env. The ksh script goes like this - #!/bin/csh exec /usr/local/bin/ksh -i function... (3 Replies)
Discussion started by: m_shamik
3 Replies

9. Shell Programming and Scripting

csh failing to call an 2 embedded csh script

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)
Discussion started by: pollsizer
1 Replies

10. Shell Programming and Scripting

Help required with a Csh script to read data from a file

Dears, This is what i want.. I need to read a comma separated text file whose name is config.txt. whose content is like ; bscnara,btserrr bscsana,btssanacity ..... i need to read the first string and second string and use it to execute a another shell script. This is the logic. ... (1 Reply)
Discussion started by: fizzme
1 Replies
Login or Register to Ask a Question