Help in tcsh script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help in tcsh script
# 8  
Old 08-18-2012
Code:
Linux cmslpc10.fnal.gov 2.6.18-274.12.1.el5 #1 SMP Tue Nov 29 11:14:39 EST 2011 x86_64 x86_64 x86_64 GNU/Linux

---------- Post updated 2012-08-18 at 07:28 AM ---------- Previous update was 2012-08-17 at 12:32 PM ----------

Hi,
I am not sure as how shall I go ahead with it. I mean changing the shell or something.

Here is the output of the following command:
Code:
[pooja04@cmslpc10 ~/CondorJobs]$ which sh
/bin/sh
[pooja04@cmslpc10 ~/CondorJobs]$ whereis sh
sh: /bin/sh /usr/share/man/man1p/sh.1p.gz /usr/share/man/man1/sh.1.gz
[pooja04@cmslpc10 ~/CondorJobs]$

I would be really happy if bash scripts can run there. Just to mention, I do use simple bash scripts there. And they work. But this particular one failed.

Thanks
Pooja
# 9  
Old 08-18-2012
OK, let me spell it for you. Literal transcription into bash:
Code:
#!/bin/bash  

TARGETPATH=$2 
Max=3 
Card=card_Data2011AB_Zee_40Ge

#Loop  (no function here)
for i in {0..7} ; do     
    echo "SHELL SCRIPTING ================ $i =============="
    cp $FILE $TARGETPATH
    if [[ $i -eq 0 ]] ; then
         source $TARGETPATH
         echo 'Press [Enter] key to continue...'
         read thisvar
         rm $TARGETPATH
     elif [[ $i -lt $Max ]] ; then
         perl -i.bak -pe 's/(file)(\d{1,})/$1 . (1 + $2)/ge' $Card
         cp $FILE $TARGETPATH
         source $TARGETPATH
         echo 'Press [Enter] key to continue...'
         read thisvar
         rm $TARGETPATH
       elif [[ $i -eq $Max ]] ; then
            perl -pi.bak -e 's/file/file1/g' $Card
            echo "Its About To Terminate...Enjoy Scripting"
      fi
done

# 10  
Old 08-25-2012
Quote:
Originally Posted by nrjrasaxena
I would be really happy if bash scripts can run there. Just to mention, I do use simple bash bourne scripts there. And they work. But this particular one failed.

Thanks
Pooja
Fixed that for you.

Not all Bourne shells are BASH. BASH is a Bourne shell, with extended features that a generic Bourne shell doesn't have -- like arrays, and functions.

There is also more than one version of BASH. Some of them support more things than others. Only very new versions of BASH have direct regex support for example, i.e. [[ "$STRING" =~ /regex/ ]] so don't use that if you don't know your system will have have BASH and a very new bash at that.

Avoiding BASH features will make your scripts much closer to generic Bourne scripts, which should theoretically work equally well in bash, sh, and ksh. You may be surprised how much you can do without them; a lot of things people use arrays for can be replaced with set --, proper use of the read command and IFS, or simple string-splitting, for instance.
These 2 Users Gave Thanks to Corona688 For This Post:
# 11  
Old 08-26-2012
Thanks Corona for the useful information.
It is resolved now.

Pooja
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Regular expressions in tcsh script

Hi, I have a shell script in tcsh to which I pass an argument, the length of which can vary. The possible values of the argument are the letters -c,s,i,q,a. and also a combination of these letters. (e.g: cs,si,ca,iq,qa,csq,acs,csia ..etc). The order of the letters does not matter. My problem... (2 Replies)
Discussion started by: Vaisakh P
2 Replies

2. Shell Programming and Scripting

Tcsh complete (autocomplete) script

I cant figure out how the complete function works in tcsh. 1. I whould like it to complete after writing my_program.py with either start or stop. I have tried to do something like this in .cshrc.user: complete my_program.py \ 'c/start/' \ 'c/stop/' However i cant get it to... (1 Reply)
Discussion started by: mr_cad
1 Replies

3. Shell Programming and Scripting

tcsh env setting using shell script

Hi All, I have made a file file usercreate.sh & it has to run in tcsh env & needs some path to be set. my script is as below. ########################## #!/bin/csh setenv PATH "/usr/lib/java/class" setenv LD_LIBRARAY_PATH ########################### but when i am ruuning my script... (1 Reply)
Discussion started by: ajaincv
1 Replies

4. Shell Programming and Scripting

[Basic Query]bsh script in tcsh shell

I am a beginner (Just 2 days old:o ), i will really appreciate if you can solve my silly queries as below: Lets say i write a script like this #!/bin/bsh clear #to read name from keyboard echo "your name please.." read fname echo "you just entered $fname" exit 0 My environment is... (2 Replies)
Discussion started by: animesharma
2 Replies

5. Shell Programming and Scripting

Help with gawk array, loop in tcsh script

Hi, I'm trying to break a large csv file into smaller files and use unique values for the file names. The shell script i'm using is tcsh and i'm after a gawk one-liner to get the desired outcome. To keep things simple I have the following example with the desired output. fruitlist.csv apples... (6 Replies)
Discussion started by: theflamingmoe
6 Replies

6. Shell Programming and Scripting

tcsh: not run script (if: Badly formed number)

Hello I have Linux Debian & tcsh shell. My mini script not run :(. Startup script displays a message: user@host:dir% ./test if: Badly formed number. script: #!/bin/tcsh -f #script check size files systems set x = `df -h /usr | tail -n1 | awk '{ print( $5 ); }'` set y = 60% if ($x... (5 Replies)
Discussion started by: moskovets
5 Replies

7. Programming

help wid C-script in tcsh

Hello Freinds I have just started off with Unix (TCSH) although I have a pretty sound background with C-programming. Kindly convey any error in foll script. #include<stdio.h> #include<math.h> #define PI 3.142857 main () { float r, A; printf("Enter the value of radius: "); scanf(" %f... (12 Replies)
Discussion started by: mahendrakamath
12 Replies

8. Shell Programming and Scripting

tcsh I can't get script to work :(

I have an export utility that exports documents from the native file to text. This is the way I would run it from the command line: expage "file" > "file.txt I am trying to loop through all the documents in the directory and expage them, here is the code: #!/usr/bin/env tcsh foreach file... (8 Replies)
Discussion started by: Fred Goldman
8 Replies

9. Shell Programming and Scripting

Help me with this tcsh script.!!!!

I need to write a tcsh script which would compare files in the two folders and then send me a mail saying which of the files are missing.For eg 1) I have this folder1 containing all the files which must land on folder2 on a daily basis. 2) If a file is present in folder1 but not in... (6 Replies)
Discussion started by: kumarsaravana_s
6 Replies

10. Shell Programming and Scripting

how to call a perl script from tcsh?

Hi I am not sure how to call a perl script from a tcsh shell. do i need to set any environment variables? your help is appreciated Thanks (1 Reply)
Discussion started by: megastar
1 Replies
Login or Register to Ask a Question