The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Query result table display class 2008.06.08 (Default branch) iBot Software Releases - RSS News 0 06-09-2008 12:40 PM
display the result of wc -l with words before and after the result melanie_pfefer UNIX for Dummies Questions & Answers 3 04-30-2008 08:33 AM
display result from user input thms_sum Shell Programming and Scripting 13 02-01-2008 05:34 AM
Search for a pattern from the result of search boopathi_d Shell Programming and Scripting 3 12-05-2007 09:54 AM
Display result one page at a time nickaren UNIX for Dummies Questions & Answers 4 09-10-2003 02:15 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-06-2008
neillsm neillsm is offline
Registered User
  
 

Join Date: Oct 2008
Location: Plymouth,UK
Posts: 2
Question csh script to search for files and display result

Hello all. I'm a long time browser, first time poster...Be gentle :-)

I don't use csh much, but have been asked to make a small script for our HP-UX systems to search for a report file(s) or summary file and display the result (I was using vuepad, but this probably is just
complicating things)

My latest error is <if: expression> after if ($type =="R".... I can't see what's wrong.. Can anyone help..?

Here's the code.

#!/usr/bin/csh
set sumdir = ( /users/probe/buffer/summary/ )
set reportdir = ( /users/probe/buffer/reports/)
printf "\n enter lot number, lower case, \n E.G. p260091p1 \n"
set lot = $<
printf "\n Report or Summary \n (R or S) \n ? "
set type = $<
if ( $type == "R" ) then
type ="r"
set files = ( `ls $reportdir | grep $lot ` )
endif
if ( $type =="S" ) then
$type ="s"
set files = ( `ls $sumdir | grep $lot ` )
else
printf "\n Type only R or S \n "
endif


set z = 1
printf "\nWHich file do you want to view?\n\n"
while ($z <= $#files)
printf "\tFILE %2d = %s\n" $z $files[$z]
set z = $z + 1
end
set last = $z - 1
printf "\nSelect (0-$last):"
set choice = ($<)
if ( $choice < 0 || $choice > $last ) then
printf "No Such File.\n"
goto END
endif
if ( $choice > 0 ) then
set FILE = ( $files[$choice] )
else
set FILE = ( $files )
endif
foreach oneFILE ( $FILE )

if $file ="r" then

/usr/vue/bin/vuepad $reportdir$oneFILE
else
/usr/vue/bin/vuepad $sumdir$oneFILE
endif
end
END:
#EOF
  #2 (permalink)  
Old 10-06-2008
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
  
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,891
Are you sure you get the error at the if ( $test == "R" ) ??

When I ran your script, I got the same error at the == "S" part. There you seem to need a space between == and "S".
  #3 (permalink)  
Old 10-06-2008
neillsm neillsm is offline
Registered User
  
 

Join Date: Oct 2008
Location: Plymouth,UK
Posts: 2
Why couldn't I see that..? I am just careless after writing so much code in langages that just don't care about these things..

My next sticky point is

while ($z <= $#files)
printf "\tFILE %2d = %s\n" $z $files[$z]

set z = $z + 1
end

Is the syntax for <while> ok? When executed I get ... files: Undefined Variable.
  #4 (permalink)  
Old 10-06-2008
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
  
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,891
I don't know anything about arrays in csh.
  #5 (permalink)  
Old 03-08-2009
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
  
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,891
Do you still need help with this?
Closed Thread

Bookmarks

Tags
csh, csh arrays, unresolved

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:29 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0