Command not found errors when running csh script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Command not found errors when running csh script
# 1  
Old 02-17-2011
Command not found errors when running csh script

I am trying to find the number of files whose name starts with uni.
Below is the code but it is giving error. Smilie

Code:
#!/bin/csh
FILES_NAME ='files_list';
FILE_NAME_PATTERN = 'uni*';
NO_OF_FILES;
ls -l $FILE_NAME_PATTERN > $FILES_NAME ;
NO_OF_FILES = `wc -l $FILES_NAME`;
echo $NO_OF_FILES;

When run give the following warnings.

Code:
$ ./unix_4.sh
FILES_NAME: Permission denied.
FILE_NAME_PATTERN: Command not found.
NO_OF_FILES: Command not found.
FILE_NAME_PATTERN: Undefined variable.
$

But when the following commands are issued
Code:
ls -l uni* > files_list and
wc -l files_list

runs perfectly.

What is the problem SmilieSmilie

Last edited by pludi; 02-17-2011 at 08:38 AM..
# 2  
Old 02-17-2011
You should have NO space before and after the sign =

in csh, you should use

Code:
set var=value

for example:
Code:
set FILES_NAME='files_list'

and remove the line:
Code:
NO_OF_FILES;

This User Gave Thanks to ctsgnb For This Post:
# 3  
Old 02-17-2011
Re:Shell scripting

For the same query as above
Let say I want to get the absolute path of all the file found using ls

How to do that ??
# 4  
Old 02-17-2011
Not sure about what you are willing to get ... maybe something like :

Code:
find $PWD -type f -prune

?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Linux csh script going to Suspended (tty output) when running with & (bg)

i have strange behavior i have csh file that run java process something like this : run_server.csh #!/usr/bin/tcsh java -Dtest=testparam -cp ${TEST}/lib/device.jar:${TEST}/conf:${TEST}/lib/commons-logging-1.1.1.jar com.device.server when i run it like this :... (7 Replies)
Discussion started by: umen
7 Replies

2. Shell Programming and Scripting

When i am trying to execute export command within a shell script it is saying command not found.

I am running the export command within a view to use that value inside my build script. But while executing it it is saying "export command not found" My code is as follows: -------------------------- #!/bin/sh user="test" DIR="/bldtmp/"$user VIEW="test.view1" echo "TMPDIR before export... (4 Replies)
Discussion started by: dchoudhury
4 Replies

3. UNIX for Dummies Questions & Answers

Invalid option errors running shell script

The script below fails with the following error messages: gzip: invalid option -- 'w' Try `gzip --help' for more information. mysqldump: Got errno 32 on write cp: invalid option -- 'w' Try `cp --help' for more information. rm: invalid option -- 'w' Try `rm --help' for more information. ... (1 Reply)
Discussion started by: ANNACTION
1 Replies

4. UNIX for Dummies Questions & Answers

csh command not found

I get a "command not found" error when I run the csh command. I also get this error when I start a new session since my default shell is c shell. Any pointers as to what is going on? I am trying to set some paths using the .cshrc file and need to use the csh command for this. Thanks. (1 Reply)
Discussion started by: kannyg
1 Replies

5. Shell Programming and Scripting

surpressing errors while running script

I have written shell script to find out pairsuspends in our environment.But when i run the script iam getting an error for the Pair which are not active.Below are the error am getting pairvolchk -g up1012 -I11 pairvolchk : execution error. pairvolchk: Unmatched CTGID within the group Refer... (3 Replies)
Discussion started by: zeebala1981
3 Replies

6. Shell Programming and Scripting

Compilation errors in running configure script

Hi all, I tried to cross compile Ghostscript-8.54 source. I am getting some errors during cross compilation. I have pasted the errors below. CC=arm-unknown-linux-gnu-gcc LD=arm-unknown-linux-gnu-ld ./configure --host=i686-pc-linux-gnu --target=arm-unknown-linux-gnu --without-x && make ... (2 Replies)
Discussion started by: siva4ever
2 Replies

7. Shell Programming and Scripting

Menu list in Unix csh - command not found

Hello, im taking a class of Unix and i dont really know much about it, im trying to create a list of menu a user would select from and im very lost. Basically it will have 5 options, the user will chose from: 1. list files in the pwd 2. display date and time 3. is the file file or directory 4.... (5 Replies)
Discussion started by: morava
5 Replies

8. Shell Programming and Scripting

how to execute a sh command from a csh script

Hi everyone, I have a csh script that works fine but the output of an rsh command is different if I use boune shell instead cshell. Is there the possibility to execute only this command in bourne shell from a script declared cshell? Thanks Christian (2 Replies)
Discussion started by: bonovox
2 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

how can i check in csh if command found or not found ?

hello all im trying to use in sun Solaris the information received from the top command now i several machines that dont have install the top program so when im running the script im geting error saying after im running this code : set MemoryInfo = `top | grep Memory` if (... (2 Replies)
Discussion started by: umen
2 Replies
Login or Register to Ask a Question