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


Reply
  Search this Thread
Old 08-19-2008, 10:22 AM   #1
nanxy
LQ Newbie
 
Registered: Jul 2008
Posts: 16

Rep: Reputation: 0
tcsh script problem


hi~ all ~ there is a script like this :


Code:
 set FilePrefix=${HdfFile:r}
 ${BinDir}/CloudStatsModis   ${InputDirectory}   ${FilePrefix}.class
${InputDirectory}/stats
CloudStatsModis is an executable file when I tried to run it .the file
prefix included the path of the file. And I just want to include the
file name not the path. How can I do that ?
Thank you
 
Old 08-19-2008, 10:44 AM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
You need to add BinDir to the PATH.

I would recommend using bash or another borne style shell for scripting - csh style shells are a little limited IMO.

However, assuming you wish to continue with tcsh, the syntax to set the PATH will look something like this:
Code:
setenv PATH "${PATH}:${BinDir}"
You will then be able to use simply "CloudStatsModis" to run it.
 
Old 08-19-2008, 11:00 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Given the answer from matthewg42, I'm not sure about the sense of the original question anymore. I interpreted the problem as related to the value of the variable FilePrefix. Anyway, here is my answer: if you want to strip out the path from the FilePrefix variable you have to apply another modifier to HdfFile:
Code:
set FilePrefix=${HdfFile:r:t}
where t removes all leading pathname components, whereas r removes a filename extension. You can apply multiple modifiers simultaneously by preceding each of them with a colon.
 
Old 08-19-2008, 11:07 AM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
I think I did not read the OP very carefully... hehe, always good to throw a spanner in the works that way.
 
Old 08-19-2008, 12:35 PM   #5
nanxy
LQ Newbie
 
Registered: Jul 2008
Posts: 16

Original Poster
Rep: Reputation: 0
it works~ Thank you very much~
 
  


Reply



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
tcsh shell script assignment problem BrianK Programming 4 01-18-2008 10:32 PM
How to get a job ID of grand child process? (tcsh script) kaz2100 Programming 1 12-12-2007 06:12 PM
tcsh script, replace word in file true_atlantis Programming 10 02-17-2006 01:24 PM
tcsh script: how to see if an env var is defined? BrianK Programming 1 06-07-2004 10:12 PM
Ping Random IPs using a tcsh script.. zeppelin Programming 7 08-07-2003 11:07 AM

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

All times are GMT -5. The time now is 10:52 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