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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
pass variable from awk to shell script user_prady Shell Programming and Scripting 3 04-17-2008 05:43 AM
Is it possible to pass variable from awk to shell back unishiva Shell Programming and Scripting 12 03-03-2008 01:44 PM
Is it possible to pass variable from awk to shell script user_prady Shell Programming and Scripting 3 12-18-2007 10:06 AM
How to pass Shell script variable to awk HIMANI UNIX for Dummies Questions & Answers 3 07-16-2007 12:23 AM
How to pass a oracle variable back to the shell script Jtrinh UNIX for Dummies Questions & Answers 3 07-11-2005 02:07 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 08-22-2005
sam70 sam70 is offline
Registered User
  
 

Join Date: Apr 2005
Posts: 8
How to Pass variable to shell Script

Hi ,

i am beginner to Unix, I have one small script which execute java programme,it has java command input output structure . Right now i have given Input output structure manually that is on same directory, now how can i pass that by commandline

#!/bin/sh

java Classjava input.txt output.xml output.structure


How can i pass variable parameter from command line.

Thanks

sam70
  #2 (permalink)  
Old 08-22-2005
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
#!/bin/sh

java Classjava $1 output.xml output.structure

Now that $1 will be replaced by the first command line argument. You can use $2, $3, etc as well.
  #3 (permalink)  
Old 08-23-2005
sam70 sam70 is offline
Registered User
  
 

Join Date: Apr 2005
Posts: 8
Regarding passing variable

Hi ,

I have tried putting $1 $2 but it doesnt work

Thanks

sam70
  #4 (permalink)  
Old 08-23-2005
dangral dangral is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2002
Posts: 699
Can you copy and paste the results?
  #5 (permalink)  
Old 08-23-2005
sam70 sam70 is offline
Registered User
  
 

Join Date: Apr 2005
Posts: 8
Regarding Variable parameter to be passed

Hi ,

Here is message

Usage: TFFtoXML <output.xml> <input.flat> <input.ffd> [logfile]


this is java command to be executed on shell script. this output we see when
we execute this on command line in local machine.it is a .bat file and we do
ff2xml and enter then it gives this information as above which i see when i put $1 $2 . But it not asking for variable input.

THanks

sam70
  #6 (permalink)  
Old 08-23-2005
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
It won't ask for variable input. It will behave the way you requested in your first post. Remember this? "How can i pass variable parameter from command line."

That script is in a file. The file has a name. Somehow you invoke the script by name. Let's say that you named the script "fred". You might use:
fred
./fred
/some/path/to/fred
when you run it. That is the command line. Put a space after fred. Type another word. That word will be $1 inside the script.
./fred input.txt
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 11:47 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