translate ksh code to csh code


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting translate ksh code to csh code
# 1  
Old 09-26-2010
translate ksh code to csh code

hi all,
Can any 1 help me translate this korn shell code to C shell code :
Code:
email=$(grep "^$1" $folder/config_2.txt | awk '{print $2'})

In config_2.txt the content is :
Quote:
which mean in korn shell , $1=groupname and $2=email address.
Now i need to write in C shell script,when i set the value as variable while be like this:
Quote:
var[1] = group1
var[2] = alan@gmail.com
var[3] = group2
var[4] = susan@email.com
var[5] = group3
var[6] = alice@gmail.com
Compare to Korn shell,when set as variable is like this:
Quote:
var[1] = group1
var[2] = alan@gmail.com
var[1] = group2
var[2] = susan@email.com
var[1] = group3
var[2] = alice@gmail.com
# 2  
Old 09-26-2010
Quote:
Originally Posted by proghack
hNow i need to write in C shell script,when i set the value as variable while be like this:

Code:
var[1] = group1
var[2] = alan@gmail.com
var[3] = group2
var[4] = susan@email.com
var[5] = group3
var[6] = alice@gmail.com

csh code:
  1. #!/bin/csh
  2. set array = `tr \\\n \  < file`
  3. echo $array[1]
  4. echo $array[6]
# 3  
Old 09-26-2010
hi danmero,
wht u mean by this part :
Code:
set array = `tr \\\n \  < file

for this ksh code :
Code:
email=$(grep "^$1" $folder/config_2.txt | awk '{print $2'})

The output should be like this :
Quote:
$email = group1 alan@gmail.com
$email = group2 susan@gmail.com
$email = group2 alice@gmail.com
Actually it mean read row by row and column.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh code explanation

Hi. Can somebody please explain the following lines of KSH code for me? The code checks all sub directories in a specific location which are numbered (E.g. test_01, test_02 ... etc.), then finds the one with highest number and extracts that number from the dir name into the variable num. I'd just... (9 Replies)
Discussion started by: user052009
9 Replies

2. Shell Programming and Scripting

Translate csh to ksh

Hi! I need to translate those line in csh (to initialise variable) into ksh construct. Any help would be appreciated! I don't know how to replace them :( Thanks Hulu setenv TestHul "$0 $*" setenv JG `setenvp "JG" "" "$*"` setenv A_1 `setenvp "A_1" "NA" "$*"` Please use next time... (2 Replies)
Discussion started by: patator67
2 Replies

3. UNIX for Dummies Questions & Answers

Help translate code

Hi, all of you!!! I have this code and I won to build-in some more code. I know this is a lot of code. if ; then if ; then SYSROOT="$1" S_SCRIPT="cd $1 ; ./etc/rc.sysinit 2>&1 &" fi else ... (22 Replies)
Discussion started by: jokerper
22 Replies

4. Shell Programming and Scripting

translate a short csh script to bash

Hi, I have a csh: set NODES = `cat $HOST_FILE` set NODELIST = $TMPDIR/namd2.nodelist echo group main >! $NODELIST foreach node ( $NODES ) echo host $node >> $NODELIST end @ NUMPROCS = 2 * $#NODES I am very frustrated to translate it to bash: NODES = `cat... (3 Replies)
Discussion started by: rockytodd
3 Replies

5. Shell Programming and Scripting

csh code to ksh code

I have this code using csh and want to convert it to ksh to include this thinking into my ksh scripts. while ( $iarg < $narg ) MATH iarg = $iarg + 1 set arg = $argv set opt=` echo $arg | awk 'BEGIN { FS="=" } { print $1 }' ` set par=` echo $arg | awk 'BEGIN { FS="=" } {... (2 Replies)
Discussion started by: kristinu
2 Replies

6. Shell Programming and Scripting

HowTo translate KSH Scripts to DOS Batch Files ?

Hi there, in near future I have to change my work surrounding from HP UNIX to Windows Vista (great to get rid of old hardware :), but bad to loose UNIX :( ). As I heavily use KSH scripts to do my job, I was wondering, if there is any HowTo available, supporting me in re-writing the scripts to... (4 Replies)
Discussion started by: Joe-K7
4 Replies

7. Shell Programming and Scripting

python code...convert to ksh or sh

Helloo... I am not much familiar with python..I found this small script in python I even do not have python on my computer...can anyone help me out to convert this into ksh or sh.. PLEASE any help I will appreciate.. here is python code.. #!/usr/bin/env python import random # Get a... (3 Replies)
Discussion started by: amon
3 Replies

8. UNIX for Dummies Questions & Answers

Csh Vs Ksh

I created a simple script and attempted to run it. All that the scrip contained was "ls -l". At first I received the message "ksh: run_dir: not found" I then tried typing "csh run_dir" This time the script worked. typing echo $SHELL produced /bin/ksh I would like to understand why this... (4 Replies)
Discussion started by: SUSANR9999
4 Replies

9. Shell Programming and Scripting

\!* in csh what is it for ksh

Hey guys, Hopefully a simple question for you. In csh I have an alias that looks like: alias ff 'find . -name \!* -print' and can therefore perform a search for a file by typing: ff filename The same comand does not work in ksh alias ff="find . -name \!* -print" I get: find:... (3 Replies)
Discussion started by: timsk
3 Replies

10. Programming

Exit Code in HP-UX KSH.

In one of my programs another process is called using the system command e.g. lv_error = system("myproc"); where lv_error is declared as an int. myproc would be returning 0 for success and 1 for failure. e.g. if (success) { return(0); }else{ return(1); } When the return code... (3 Replies)
Discussion started by: mbb
3 Replies
Login or Register to Ask a Question