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
passing parameter 4m shell script to a DB stored procedure hema2026 Shell Programming and Scripting 0 11-16-2007 06:55 AM
How to pass a parameter from one Shell-script to another Shell-script subodhbansal Shell Programming and Scripting 2 09-22-2007 05:19 AM
passing parameter from Shell-script to Sql-script subodhbansal Shell Programming and Scripting 0 09-21-2007 06:15 AM
Shell script with input parameter jhmr7 UNIX for Dummies Questions & Answers 1 07-13-2005 12:04 AM
parameter file for a shell script bryan Shell Programming and Scripting 2 02-25-2005 12:58 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 11-07-2001
cmitulescu cmitulescu is offline
Registered User
  
 

Join Date: Nov 2001
Location: UK
Posts: 1
simple shell - how to get a parameter typed in a shell script

Hi,
I am new to unix and using linux 7.2. I would like to create a script that would make it easyer for me to run my java programms. At the moment I have to type java [path to my program]myJavaprogram

I am trying to write a script that will allow me to type something like this "myscript myJavaprogram" or maybe "myscript -myJavaprogram.
This is what I got so far

#!/bin/sh
# Print the current working directory.
java `pwd`
#end of runjava file

How do I read an argument that I would like to pass?
ie %runjava Test
And the command passed to the shell would be "java [directory]Test"


Thenk you
  #2 (permalink)  
Old 11-07-2001
kapilv kapilv is offline
Registered User
  
 

Join Date: Nov 2000
Location: India
Posts: 83
Hi

Inside a shell script you can read the arguments passed to your shell program by $1, $2, $3 .......
for e.g if your script file name is myscript and if you want to pass an argument to it like (myscript arg1) then inside myscript you can refer the arg1 by $1.

Hope this helps
  #3 (permalink)  
Old 12-04-2001
brianb brianb is offline
Registered User
  
 

Join Date: Dec 2001
Location: Portland, OR
Posts: 1
Question regular expressions and command-line arguments

As a follow-up question (that seems related):

I'm running .kshrc and want to script or alias the following:
ls -alF <i>regex</i> | more

I have not found how to pass an argument inside an alias
(e.g. alias dir='ls -alF $1 | more' does NOT work).

The following script 'dir' works:
#!/bin/ksh
ls -alF $1 | more

however, if I pass it an expression like '*.eva' it will only ls the first filename with the .eva extension (not ls all of the files with the .eva extension).

_Anyone_ who's read this far already has my sincere appreciation! If you can point me to man pages to help me solve this problem I'd appreciate it even more!
  #4 (permalink)  
Old 12-05-2001
Jimbo
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
When you run your 'dir' script, such as:

dir *.eva

the shell expands this, same as if you had typed:

dir file1.eva file2.eva file3.eva

Your script processes only the first of these ($1). You could keep the shell from expanding it on the command line with:

dir "*.eva"

so that your script gets the unexpanded *.eva as $1. Or you could change $1 in your dir script to $*.

man ksh documents treatment of shell variables.
  #5 (permalink)  
Old 01-09-2009
kany2k kany2k is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 6
Smile Sample shell script

I am new to UNIX script can someone send me the sample script which accepts a parameter in the script and check for some condition as below

If $parm1 = "ABC"
do some process1
else
if $parm1 = 'DEF"
do some process2
fi
fi
Sponsored Links
Closed Thread

Bookmarks

Tags
regex, regular expressions

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:50 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