![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Declaring Global Variables in KLD | int80h | BSD | 1 | 01-21-2008 05:11 AM |
| ksh functions | scriptingmani | Shell Programming and Scripting | 3 | 07-06-2007 04:15 AM |
| functions in | Raom | Shell Programming and Scripting | 6 | 07-21-2006 12:06 AM |
| Declaring Local Arrays | ksh | Shell Programming and Scripting | 1 | 02-22-2005 05:16 AM |
| Declaring variable environments in .cshrc | v_sharda | UNIX for Dummies Questions & Answers | 2 | 09-23-2002 07:25 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi all,
It might seem like a very trivial question but I am new to shell scripting so excuse for that. I have an existing script in CSH. I need to create a function in the script which takes some parameters and returns a result. Can someone please let me know the syntax for function declaration and how to call the function passing parameters. Also if someone has a good tutorial with examples on CSH please send me the link. Thanks in advance. Regards, Tipsy |
| Forum Sponsor | ||
|
|
|
|||
|
I had a similar problem with declaring the functions in csh.
A simple script as below worked well in sh shell #! /bin/sh display() { echo "Inside display()" } echo "calling display()" display however when the shell interpreter was changed to "csh" it failed with following error :- "Badly placed ()'s" It looks like csh shell scripting doesn't support functions. I have been searching over the net now for quite sometime for the function syntax in csh but never found one. Please let me know if anyone finds the solution for the same. Best Regards, brendon |
|
|||
|
Quote:
ThisIsAFunction() { echo "$1 $2" } #Main VAR1=Hi VAR2=there ThisIsAfunction $VAR1 $VAR2 ------------------- Running this script would result in: Hi there on your screen. Passing parameters to a functions is like passing arguments to a script. They are stored in $1, $2, $3 etc Running this script would result in the following |
|
|||
|
Quote:
You can trying to replace the double quotes (") by single quotes (') in the echo commands. This would work fine as long as you don't want to echo values of variables to the screen. |
|
||||
|
Quote:
you can use aliases. See: http://www.grymoire.com/Unix/CshTop10.txt Last edited by radoulov; 01-22-2007 at 01:00 PM. |
||||
| Google The UNIX and Linux Forums |