LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Closed Thread
  Search this Thread
Old 08-17-2011, 07:18 PM   #1
leavage
LQ Newbie
 
Registered: Dec 2010
Posts: 11

Rep: Reputation: 0
A for loop in an if statement tcsh


I have a program that runs the following commmands

if (-e ${CALIBPLOTS}/y*.eps) then

foreach file ($CALIBPLOTS/y*.eps)
set jpgfile = `echo $file | sed s/\.eps//g`
convert $file ${jpgfile}.jpg
end

endif


The problem I have is that with that foreach loop, if no files exist the program outputs that no file exists and stops running. So I wanted to put that if statement there so that it only runs if there is a file. But for some reason if there isn't a file it still runs the foreach loop and stops running.

Everything works fine if there is a file there.
Any ideas how I can get this to run properly
 
Old 08-17-2011, 08:08 PM   #2
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
Duplicate post of
http://www.linuxquestions.org/questi...t-tcsh-897904/

Please do not double post. It is against LQ rules.
 
Old 08-17-2011, 11:34 PM   #3
leavage
LQ Newbie
 
Registered: Dec 2010
Posts: 11

Original Poster
Rep: Reputation: 0
Sorry this was unintentional.
 
  


Closed 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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
A for loop in an if statement tcsh leavage Programming 2 08-17-2011 11:32 PM
Need help with for loop + if statement Thaidog Programming 5 05-06-2011 09:54 PM
can't put an if statement as an increment in a for loop. Why? japhy Programming 2 02-07-2009 06:07 AM
Piping into a Case Statement embedded in a while loop telecom_is_me Programming 5 07-02-2008 04:45 PM
BASH Need help figuring out how to loop SELECT statement mcdrr Programming 2 05-08-2007 04:47 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration