The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
[KSH] Split string into array piooooter Shell Programming and Scripting 3 09-01-2007 12:22 PM
String Array ravikirankethe UNIX for Dummies Questions & Answers 6 11-15-2006 12:09 PM
MAX SIZE ARRAY Can Hold it epall UNIX for Advanced & Expert Users 3 06-07-2006 05:05 AM
string to array sumitgarg UNIX for Dummies Questions & Answers 6 03-07-2005 01:56 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-27-2007
brajesh brajesh is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 2
How to hold string array in shell scripts

Gents,

Below is the Shell script which I am trying to hold a string of array that is passed from a java file. But it is not working . Can any one please help me to by fixing it.

#!/bin/csh/
set copy = ($argv[*])
echo $copy[1] >> /home/users/bavananr/rrr.log
echo $copy[2] >> /home/users/bavananr/rrr.log
echo $copy[3] >> /home/users/bavananr/rrr.log
echo $copy[4] >> /home/users/bavananr/rrr.log

this should print - Raj Sok Rajesh brajesh
------------------------------------------------------
Below is the java program that i used to call above shell script.
It sucks

public class sample
{
public static void main(String args[]) {
String strCmd = "/home/users/bavananr/Raj.sh";
String str [] = {"Raj","Sok","Rajesh","brajesh"};
Process proc = null;
try{
proc = Runtime.getRuntime().exec(strCmd,str);
}catch (Exception e) {
System.out.println("Exception occurs "+e);
}
}
}
  #2 (permalink)  
Old 03-27-2007
Dhruva's Avatar
Dhruva Dhruva is offline
Registered User
  
 

Join Date: Mar 2006
Location: India
Posts: 255
try this
Code:
col_look="this is test"
set -A look $col_look
echo "${look[1]}"
echo "${look[2]}"
echo "${look[0]}"
  #3 (permalink)  
Old 03-27-2007
brajesh brajesh is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 2
hi ,

My problem when string is "passed" as a parameter from java program and I would like to have a script how to hold the string array parameter and use it further

Thanks
  #4 (permalink)  
Old 03-27-2007
Dhruva's Avatar
Dhruva Dhruva is offline
Registered User
  
 

Join Date: Mar 2006
Location: India
Posts: 255
try this
Code:
x=$@
echo $x
set -A look $x
echo ${look[0]}
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:16 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0