New to KSH Scripting > Please Assist!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting New to KSH Scripting > Please Assist!
# 1  
Old 09-14-2008
New to KSH Scripting > Please Assist!

Array Example:
$ colors[0]=RED
$ colors[1]=GREEN
$ colors[2]=BLUE

Last edited by ora_umair; 09-15-2008 at 11:06 AM..
# 2  
Old 09-14-2008
Are you trying this on your own?
# 3  
Old 09-14-2008
Array Example:
$ colors[0]=RED
$ colors[1]=GREEN
$ colors[2]=BLUE

Last edited by ora_umair; 09-15-2008 at 11:06 AM..
# 4  
Old 09-14-2008
This means you need to know $# and $@ plus set -A
Code:
#!/bin/ksh
if [[ $#  -eq 2 ]] ; then # two parameters
   set -A arr $@
else
   echo "bad parameters"
   exit 1
fi
# function goes here

# call to function goes here

Next functions look like this
Code:
myfunc()
{
    echo "${arr[1]} is a parameter"

}

You get to finish writing the function and the call to the function
# 5  
Old 09-14-2008
Array Example:
$ colors[0]=RED
$ colors[1]=GREEN
$ colors[2]=BLUE

Last edited by ora_umair; 09-15-2008 at 11:06 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

KSH scripting

Hi Guys, I am trying to learn to script. first I have 2 server, A and B. A with IP 192.168.82.22. B with IP 192.168.82.44. Both with login user admin and password admin. server A will generate a file every day with name gg.log under /app/gg/20171002.log. I wish to write a script to copy the... (7 Replies)
Discussion started by: leecopper
7 Replies

2. Shell Programming and Scripting

ksh scripting

Hi All, Can you please let me know what I missed in the below function? Whenever I try to execute the script i am getting syntax error at line 101 : `fi' unexpected Function is function DELNWE5O { export ORACLE_HOME=/ora00/app/oracle/product/11.2.0/grid_1 export... (9 Replies)
Discussion started by: pvmanikandan
9 Replies

3. Red Hat

assist me in UNIX scripting

hi ... i want to monitor the httpd service whether its online or offline.. if httpd service goes offline/stopped then i need to get alert to my mail. how to do construct this script.. myself using RHEL4 ... (1 Reply)
Discussion started by: sriniv666
1 Replies

4. Shell Programming and Scripting

Help with ksh scripting in AIX

I am looking for a script which does the following Script will run daily. 1.It will get snapshot off all filesystems including nfs mounts, automounts and clearcase mounts. 2.Then it will compare new snapshot with the snapshot created in the previous run. 3.If filesystem exists in... (20 Replies)
Discussion started by: saidiya
20 Replies

5. Shell Programming and Scripting

Problem with Ksh scripting

Hi, Below is the code for my script #!/bin/ksh for file in "file1.txt" "file2.txt" "file3.txt" "file4.txt" do L="$(tail -1 $file)" NUM=${L%%|*} DAT=${L##*|} echo $NUM echo $DAT done Now here,suppose for file1.txt L will have data like 56|06-07-2010 So, it should be (7 Replies)
Discussion started by: fidelis
7 Replies

6. Shell Programming and Scripting

Editing a ksh script > Please assist!

I am trying to edit a script that contains the following: /DBA/general/sh/rman_backup.ksh -d PROD2 -l 1 I am trying to add a logic in the script such that if /DBA/general/sh/rman_backup.ksh does not exists, then the script would return an error code of 1. Otherwise, the script continues... (4 Replies)
Discussion started by: ora_umair
4 Replies

7. Shell Programming and Scripting

ksh scripting help

I have the file as below server1 no dr aix 5300-05-03 9119-595 20-18888 yes ftp-eagle server2 no dr aix 5300-05-03 9119-595 20-18888 yes ftp-eagle server3 yes dr aix 5300-05-03 9119-595 20-18888 yes ftp-eagle server4 ... (1 Reply)
Discussion started by: praveenbvarrier
1 Replies

8. Shell Programming and Scripting

Need help with KSH scripting

Hi I need to insert a page break into a file based on matching a phrase in the file. :confused: I am doing this with a ksh script on a Unix box. Any help would be greatly appreciated. Thanks (5 Replies)
Discussion started by: scrappycc
5 Replies

9. Shell Programming and Scripting

KSH scripting question

Good day, I am trying to write a script that completes an ssh challenge to a specific server and writes output to a log. We have shared ssh keys for the script user. My challenge is a simple hostname check; ssh $host hostname My problem arrises when there is an actual challenge, be it... (3 Replies)
Discussion started by: M-Pacificorp
3 Replies

10. Shell Programming and Scripting

KSH Scripting

Will a shell script written in shell for HP/UX run on Solaris? (1 Reply)
Discussion started by: dstaller
1 Replies
Login or Register to Ask a Question