csh

How to execute .csh script with command line arguments from .csh script

So I have .csh script generate.csh I want to call another .csh script from within it. I tried ./shell_gen.csh test1 test2.prt But it runs shell_gen.csh but without command line arguments. Anyone? Thanks generate.csh #!/bin/csh ./shell_gen.csh test1 test2.prt shell_gen.csh #!/bin/csh set source = output ########################...

How can I make the list of letters from A to Z and iterate through them in the shell?

Say I want to iterate from letter A to letter Z in csh shell. How do I succinctly do that? In bash I would do something like for i in 'A B C ...Z'; do echo $i; done The point is I don't want to write A through Z, I want something like [A-Z] Can you suggest a one line suggestion in AWK or Perl? ...

Why do unix background processes sometimes die when I exit my shell?

I wanted to know why i am seeing a different behaviour in the background process in Bash shell Case 1: Logged in to Unix server using Putty(SSH) By default it uses csh shell I changed to bash shell typed sleep 2000 & press enter It gave me the job number. Now i killed my session by clicking the x in the putty window Now open anothe...

How do you manage/store/arrange your alias in *nix?

I have a million of alias stored in my .cshrs file. I wonder if it is preferred way or people use other files to do it and then loaded into the environment. How do you do it? ...

extract filename from path in csh shell -- from list of files

How to extract filename from the path; i have a list of files. I'm using csh shell, and have awk, sed, perl installed. /dfgfd/dfgdfg/filename should give me filename I tried basename: find $PROJDIR -name '*.c' -o -name '*.cc' -o -name '*.h' | xargs grep -l pattern | xargs basename and it gave me the following error: basen...

csh list of commands like ksh { list; }

Hi, In bourne-compatible shells, the { list; } syntax causes the complete list of commands to be read by the shell before executing it, without opening a new shell. Is there anything similar for the csh? Thanks. ...

How to use for loops in command prompt in csh shell -- looking for decent one liners

coming from bash shell, I missed on an easy rolling of loops (for i in (...); do ... done;) Would you post typical one-liners of loops in cshell? ONE LINERS PLEASE, and not multiple-lines thx ...

CShell word replacement

Hey, I have a short text file with the following syntax: FileName: some name Version: 3 Length: 45 hello, this is an irrelevant, unimportant text. So is this line. Now, I'm trying to write a script that replace the version number with a given new number. Anyone knows how to? I really don't mind it to be ugly thanks, Udi ...

evaluating environment variable from file in csh

I have a config file that contains the following line: pre_args='$REGION','xyz',3 Using perl from within a csh script I can evaluate environment variable $REGION like so: set pre_args = `grep -v '^#' $config_file | grep pre_args | cut -f 2 -d = | sed 's/ //g'` if ("$pre_args" != "") then set pre_args = `echo $pre_args | perl -ne '...

Remove symbol in shell

I'm new to shell scripting, right now using csh and let's say I have a line in my configuration file like this: 127.0.0.1:2222 127.0.0.2:3333 127.0.0.3:4444 All I want is to parse it for two variables in array : 2222 3333 4444 And another one 127.0.0.1 127.0.0.2 127.0.0.3 ...

How to redirect stdout and stderr from csh script.

For the following script install.csh: #!/bin/csh -f tar -zxf Python-3.1.1.tgz cd Python-3.1.1 ./configure make make install cd .. rm -rf Python-3.1.1 Intended use: ./install.csh |& tee install.log How can I change the script so that I still get a install.log and the output on console without asking the user to do the redirecting...

Syntax error in CShell Script

Write Script to read a positive integer number then it computes the following sequence: If the number is even, halve it If it is odd multiply it by 3 and add1 You should repeat this process until the value is 1, printing out each value and how many of these operations you performed. #! bin\csh echo "please enter any integer number :) ...

Explain the deviousness of the Perl "preamble"

The Perl manual describes a totally devious construct that will work under any of csh, sh, or Perl, such as the following: eval '(exit $?0)' && eval 'exec perl -wS $0 ${1+"$@"}' & eval 'exec /usr/bin/perl -wS $0 $argv:q' if $running_under_some_shell; Devious indeed... can someone please explain in detail how this works? ...

"exec source <script>" does not work in tcl

Hi all, I'm trying to call a script in Tcl with the command: exec source <script path> and I get the error couldn't execute "source": no such file or directory How can I call another script from tcl? Edit: I am running a command I got from another person in my office. I was instructed to run "source " explicitly with source. So i...

ampersand at beginning of a line in csh

What does an ampersand at the beginning of a line do in csh? It seems to be ignored (with no error message), but why? ...

What are the syntax changes from the shell script to the cshell script?

I just came to know that .sh files don't use set and spaces around = are not allowed, while this is allowed in a .csh file. Is there some place that you can point me to where I can find all these minor differences? ...

csh idioms to check for environment variable existence?

I've got a few csh scripts where I need to check that certain environment variables are set before I start doing stuff, so I do this sort of thing: if ! $?STATE then echo "Need to set STATE" exit 1 endif if ! $?DEST then echo "Need to set DEST" exit 1 endif which is a lot of typing. Is there a more elegant idiom for c...

How to view some data in gvim without saving it first?

For example suppose I do a certain man or maybe a grep. I want to see the results using gvim without the normal procedure of saving them first and opening the saved file [because I don't need the results once I view them] I tried two ways, both the methods fail: a) man gcc | gvim //opens a blank gvim window b) man gcc > gvim //sa...

csh script inherit envirionment variables?

I found an odd problem when I run a simple csh script on Solaris. #!/bin/csh echo $LD_LIBRARY_PATH Let's call this script test. When I run this: shell> echo $LD_LIBRARY_PATH shell> /usr/lib:/usr/openwin/lib:/usr/dt/lib:/usr/local/lib:/lib:/my_app/lib shell> ./test shell> /usr/lib:/usr/openwin/lib:/usr/dt/lib:/usr/local/lib:/lib The...

Get the last day of the last month in csh?

How do you get the last day of the last month in csh? Here is the code so far. The cal command below almost works if you execute it from the (FreeBSD sh) command line, but I'm having trouble escaping it properly to run within a script. By almost work, I mean it returns 31, when the last day of February 2010 is 28. #!/bin/csh set last...