Understanding someone else's csh script...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Understanding someone else's csh script...
# 1  
Old 12-19-2012
Understanding someone else's csh script...

Hello all. I suspect this will be a simple case for an experienced csh scripter, but google is getting me nowhere on this one.

I'm trying to get someone else's set of scripts to work for me, and it's choking when the following script gets called:
Code:
#! /bin/csh 
if (x$1 == x) then
echo ' you must give a file name '
exit
endif
set name=$1:r
#echo 
#echo started $name
#echo
$name.job >&! $name.error
exit



It's meant to submit a series of .job files to the queue of a cluster, but something is going haywire here. The line "set name=$1:r" is baffeling to me, so if you can let me know what that means/does, I'd very much appreciate it.

Cheers.

Last edited by joeyg; 12-19-2012 at 05:39 PM.. Reason: Please wrap commands and data with CodeTags
# 2  
Old 12-19-2012
:r is a modifier that removes a file extension.

Code:
% cat myScript
#!/usr/bin/env csh

set name=$1:r

echo $name.job

% ./myScript hello.txt
hello.job
%

I found that out by reading the csh manual page Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shall script use and understanding

Below script is called as Reducer, I am not sure how it work, can some expert explain me what this script does as i am a beginner. inputfile: hi hi how are are you code: #!/bin/bash lastkey=""; -- what does this mean, because i saw in debug mode it is taking value as hi count=0;... (13 Replies)
Discussion started by: mirwasim
13 Replies

2. Shell Programming and Scripting

Help understanding the script

Could someone please help me in understanding the code below: #!/usr/bin/ksh Month=`date|cut -c5-7` Day=`date|cut -c9-10` Year=`date|cut -c27-28` Rom2Jul() { case $Month in Feb) Day=$(( $Day+31 ));; Mar) Day=$((... (27 Replies)
Discussion started by: hasn318
27 Replies

3. Shell Programming and Scripting

Help--understanding the script

Hi, New to this forum, as well as to unix scripting..need help to understand below script ... sendNotice_sp() { ATTACH=${LNXLOG:-} if ; then if ; then mail -s "$ERR_MSG" $ERR_EMAIL_TO < $ATTACH fi else mail -s "$ERR_MSG" $ERR_EMAIL_TO < /dev/null fi } afaik this is sm kind of... (6 Replies)
Discussion started by: gnnsprapa
6 Replies

4. Shell Programming and Scripting

Help understanding the script

Hi Guys, I am new to scripting , I am trying to rebuild a script based on an old script. Can someone help me figure out what the script is doing? This is only a part of the script. I am looking to interpret these two points in the scripts:- 1) test=`echo $?` while I do not... (3 Replies)
Discussion started by: rajsan
3 Replies

5. UNIX for Dummies Questions & Answers

help with understanding script

i am trying to understand this script example. the text does not explain it. can someone tell me briefly what each of the functions do. any help will be appreciated. #!/bin/bash killtree() { local _pid=$1 local _sig=${2-TERM} for _child in $(ps -o pid --no-headers --ppid... (1 Reply)
Discussion started by: iluvsushi
1 Replies

6. Shell Programming and Scripting

Need help understanding this script.

Can someone explain what is happening line by line in this script, particularly after the do statement. The script works, it renames all the files in my directory that has a date in the file name. But I would like to know more about it. #!/bin/bash newdate=12-10-1995 for file in *--* do ... (6 Replies)
Discussion started by: Harleyrci
6 Replies

7. Shell Programming and Scripting

Need help for understanding of script

# sub: find block (in cols), return line-numbers (begin-end) or 0 if notfound sub findb{ my ($exp1,$col1,$exp2,$col2)= @_; # $exp = expression to find, $col - column to search in my $cnt=0; my ($val1,$val2); my ($beg,$end); for($cnt=1;$cnt<=65536;$cnt++){ $val1 =... (3 Replies)
Discussion started by: suvenduperl
3 Replies

8. Shell Programming and Scripting

Help understanding a script

Hello everybody, Can anybody tell me of what "~" refers to in the below code snippet. lsvg $vgNAME | awk 'BEGIN {freeDISK=1} {if (($4 ~ /PP/ && $5 ~ /SIZE/) || ($4 ~ /FREE/ && $5 ~ /PPs/)) {freeDISK *= $6 }} END {print freeDISK*1024 }' Thanks in advance, (6 Replies)
Discussion started by: tenderfoot
6 Replies

9. Shell Programming and Scripting

help required in understanding this script!!!

Hi Everyone, Please find below the script, I needed to understand step by step:confused:. Please If someone can help me out i will be very greatful:D. Please Guide me in a way which can help me out in figuring what this script doing on my server. ... (1 Reply)
Discussion started by: jojo123
1 Replies

10. 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
Login or Register to Ask a Question