LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Reply
  Search this Thread
Old 10-22-2004, 12:36 PM   #1
desbyleo
Member
 
Registered: Feb 2002
Location: Erie, CO
Distribution: Red Hat 7.1
Posts: 94

Rep: Reputation: 15
Positional Parameters (arguments)


Can positional parameters in korn be resetted?
What I mean is, if I have a script that takes 3 srguments:

$ myscript arg1 arg2 arg3
...script runs and so $1 is equal to arg1; and $2 is equal to arg2, etc...

When I ran it again WITHOUT provide any arguments:

$ myscript
...

It runs with the previous arguments still in effect.

Is there a way to keep that from happening in Korn?

I know in bash, that does not happen.
 
Old 10-22-2004, 02:56 PM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492

I never saw nor can reproduce this behaviour.
Actually I could only explain what you describe if "myscript" is implementing some kind of persistance.
Can you send your script ?
Are you sure you use a "real" korn shell ?
 
Old 10-25-2004, 11:51 AM   #3
desbyleo
Member
 
Registered: Feb 2002
Location: Erie, CO
Distribution: Red Hat 7.1
Posts: 94

Original Poster
Rep: Reputation: 15
Nevermind... I just discovered what I was doing wrong.

I was "sourcing" the file instead of "executing" it (if that IS the proper term).

I was doing this:

$. ./myscript arg1 arg2

instead of

$./myscript arg1 arg2

I now know that there is a difference when it comes to environment variables.

Forgive me, I'm a newbie to scripting.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell: positional parameters... neidias Programming 1 04-04-2005 02:45 PM
What does "Syntax error in parameters or arguments" mean with Evolution mr_matti Linux - Software 3 10-26-2004 02:19 PM
positional parameters $1 $2 in sed command Warmduvet Programming 12 09-22-2004 03:56 PM
awk positional replacement qusan Programming 2 06-09-2004 10:08 AM
Help with positional parameters Read_Icculus Linux - General 7 11-02-2003 04:23 AM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 08:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration