niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Programming » shell
Passing parameters back from a function
Post new topic   Reply to topic Page 1 of 43 [637 Posts] View previous topic :: View next topic
Goto page:  1, 2, 3, ..., 41, 42, 43 Next
Author Message
Ed Morton
*nix forums Guru


Joined: 20 Feb 2005
Posts: 1073

PostPosted: Sat Feb 19, 2005 8:46 pm    Post subject: Re: How to display the each executed line of a shell script? Reply with quote

Stachu 'Dozzie' K. wrote:
Quote:
On 2005-02-09, Big and Blue wrote:

Matt Benson wrote:


When I start (in ksh) a shell script test.sh
How do I let the shell interpreter display each line he will execute
just before he is really executing it.
The display should include the real content of variables.

Can't see what this has to do with perl, but

set -x


Can't see where Matt was talking about Perl.


He posted to a large list of NGs, including a perl one.

Ed.
Back to top
Stachu 'Dozzie' K.
*nix forums Guru Wannabe


Joined: 30 Mar 2005
Posts: 250

PostPosted: Sat Feb 19, 2005 8:46 pm    Post subject: Re: How to display the each executed line of a shell script? Reply with quote

On 2005-02-09, Big and Blue wrote:
Quote:
Matt Benson wrote:

When I start (in ksh) a shell script test.sh
How do I let the shell interpreter display each line he will execute
just before he is really executing it.
The display should include the real content of variables.

Can't see what this has to do with perl, but

set -x

Can't see where Matt was talking about Perl.

--
Stanislaw Klekot
Back to top
Bit Twister
*nix forums Guru


Joined: 19 Feb 2005
Posts: 1546

PostPosted: Sat Feb 19, 2005 8:46 pm    Post subject: Re: How to display the each executed line of a shell script? Reply with quote

On Wed, 9 Feb 2005 01:05:20 +0100, Matt Benson wrote:
Quote:
When I start (in ksh) a shell script test.sh
How do I let the shell interpreter display each line he will execute
just before he is really executing it.
The display should include the real content of variables.

set -vx # enable
code to watch
set - # disable
Back to top
Bob_M
*nix forums addict


Joined: 03 Mar 2005
Posts: 77

PostPosted: Sat Feb 19, 2005 8:46 pm    Post subject: Re: How to display the each executed line of a shell script? Reply with quote

On Wed, 9 Feb 2005 01:05:20 +0100, mbens@hotmail.com (Matt Benson)
wrote:

Quote:
When I start (in ksh) a shell script test.sh
How do I let the shell interpreter display each line he will execute
just before he is really executing it.
The display should include the real content of variables.

Matt

One quick way is to run the script with: ksh -x script_name

You may have to pipe through more to be able to "see" the lines.
Back to top
Bill Seivert
*nix forums Guru Wannabe


Joined: 06 Mar 2005
Posts: 159

PostPosted: Sat Feb 19, 2005 8:46 pm    Post subject: Re: How to display the each executed line of a shell script? Reply with quote

Bob_M wrote:
Quote:
On Wed, 9 Feb 2005 01:05:20 +0100, mbens@hotmail.com (Matt Benson)
wrote:


When I start (in ksh) a shell script test.sh
How do I let the shell interpreter display each line he will execute
just before he is really executing it.
The display should include the real content of variables.

Matt

One quick way is to run the script with: ksh -x script_name

You may have to pipe through more to be able to "see" the lines.


Be careful, though. At least Sun's Bourne shell prints set -x output to
stderr, so you might need to use ksh -x script_name 2>&1 | more

Bill Seivert
seivert@pcisys.net
Back to top
Josef Moellers
*nix forums Guru


Joined: 28 Feb 2005
Posts: 426

PostPosted: Sat Feb 19, 2005 8:46 pm    Post subject: Re: How to display the each executed line of a shell script? Reply with quote

Matt Benson wrote:
Quote:
When I start (in ksh) a shell script test.sh
How do I let the shell interpreter display each line he will execute
just before he is really executing it.
The display should include the real content of variables.

set -x

and what was your Perl question?

--
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
Back to top
Villy Kruse
*nix forums Guru Wannabe


Joined: 04 Mar 2005
Posts: 117

PostPosted: Sat Feb 19, 2005 8:46 pm    Post subject: Re: How to display the each executed line of a shell script? Reply with quote

On Tue, 08 Feb 2005 20:09:40 -0700,
Bill Seivert <seivert@pcisys.net> wrote:


Quote:

Be careful, though. At least Sun's Bourne shell prints set -x output to
stderr, so you might need to use ksh -x script_name 2>&1 | more


I beleive that goes for most shell's. The shell prompt also goes to
stderr. If you realy want to catch everything in a file I would recommend
using "script", and then display the "typescript" file afterwards.

Villy
Back to top
Captain Dondo
*nix forums Guru Wannabe


Joined: 28 Feb 2005
Posts: 250

PostPosted: Sat Feb 19, 2005 8:46 pm    Post subject: Re: How to display the each executed line of a shell script? Reply with quote

On Wed, 09 Feb 2005 01:05:20 +0100, Matt Benson wrote:

Quote:
When I start (in ksh) a shell script test.sh
How do I let the shell interpreter display each line he will execute
just before he is really executing it.
The display should include the real content of variables.

Matt

OK, you probably want to start with limiting your cross posting. Many
newsreaders, servers, etc. will automatically kill messages with more than
xome arbitrary nubmer of newsgroups - usually 4 or 5. So crossposting to
a dozen groups will get you less distribution than more.

Also, pick your groups; ksh is not distributed with any linux distro that
I know of (and my knowledge is admittedly limited) because of its license.

But if you really want to know the answer to your question, I'd start with
http://www.kornshell.com/ .
Back to top
Villy Kruse
*nix forums Guru Wannabe


Joined: 04 Mar 2005
Posts: 117

PostPosted: Sat Feb 19, 2005 8:46 pm    Post subject: Re: How to display the each executed line of a shell script? Reply with quote

On Wed, 09 Feb 2005 05:42:41 -0800,
Captain Dondo <yan@NsOeSiPnAeMr.com> wrote:


Quote:

Also, pick your groups; ksh is not distributed with any linux distro that
I know of (and my knowledge is admittedly limited) because of its license.


The pdksh is, however, and that may be close enough for some of us.

Villy
Back to top
Mike Mol
*nix forums beginner


Joined: 14 Mar 2005
Posts: 17

PostPosted: Sat Feb 19, 2005 8:46 pm    Post subject: Re: How to display the each executed line of a shell script? Reply with quote

Matt Benson wrote:
Quote:
When I start (in ksh) a shell script test.sh
How do I let the shell interpreter display each line he will execute
just before he is really executing it.
The display should include the real content of variables.

Matt

I can't test this, as I don't have access to a Linux machine right now,
but you might try this:

cat test.sh | tee /dev/tty | ksh -s

You might also consider creating a ~/bin/echosh script that embodies
the above functionality, and add...

#!/home/username/bin/echosh

....to the beginning of each script you want executed in that fashion.
Back to top
Nick
*nix forums addict


Joined: 20 Feb 2005
Posts: 89

PostPosted: Sat Feb 19, 2005 8:46 pm    Post subject: Re: Wanted: GNU utility (similar to sed) to edit text files directly. Reply with quote

Thanks everyone.
It's good to know that you cant edit a file directly without a filecopy occuring.
The rename instead of copy idea should help make my task more efficient.
Regards,
Nick
Back to top
mgrd
*nix forums beginner


Joined: 06 Apr 2005
Posts: 24

PostPosted: Sat Feb 19, 2005 8:46 pm    Post subject: Re: How to display the each executed line of a shell script? Reply with quote

Matt Benson wrote:
Quote:
When I start (in ksh) a shell script test.sh
How do I let the shell interpreter display each line he will execute
just before he is really executing it.
The display should include the real content of variables.

make your shebang look like this:

#/bin/ksh -xv

where: -x print all commands incl. parms to stdout; vars are already
interpreted
-v print each line read to stdout

--
reply to usenet only
Back to top
Barry Margolin
*nix forums Guru


Joined: 24 Feb 2005
Posts: 323

PostPosted: Sat Feb 19, 2005 8:46 pm    Post subject: Re: Passing parameters back from a function Reply with quote

In article <1108697901.614706.212320@f14g2000cwb.googlegroups.com>,
"Stu" <beefstu350@hotmail.com> wrote:

Quote:
Can somebody show me the best way to pass set parameters back from a
function within a shell script. I know the following code should work
(see below) since parm1 and parm2 are global variables.

setit()
{
parm1="hello"
parm2="world"

}

parm1=""
parm2=""
setit parm1 parm2

At this point I would like to see $parm1="Hello"

setit ()
{
eval \$$1='"hello"'
eval \$$2='"world"'
}

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Back to top
Stachu 'Dozzie' K.
*nix forums Guru Wannabe


Joined: 30 Mar 2005
Posts: 250

PostPosted: Sat Feb 19, 2005 8:46 pm    Post subject: Re: How to display the each executed line of a shell script? Reply with quote

On 2005-02-09, Matt Benson wrote:
Quote:
When I start (in ksh) a shell script test.sh
How do I let the shell interpreter display each line he will execute
just before he is really executing it.
The display should include the real content of variables.

man ksh
ksh -x scriptname.sh

--
Stanislaw Klekot
Back to top
Big and Blue
*nix forums addict


Joined: 21 Feb 2005
Posts: 95

PostPosted: Sat Feb 19, 2005 8:46 pm    Post subject: Re: How to display the each executed line of a shell script? Reply with quote

Matt Benson wrote:

Quote:
When I start (in ksh) a shell script test.sh
How do I let the shell interpreter display each line he will execute
just before he is really executing it.
The display should include the real content of variables.

Can't see what this has to do with perl, but

set -x


--
Just because I've written it doesn't mean that
either you or I have to believe it.
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 43 [637 Posts] Goto page:  1, 2, 3, ..., 41, 42, 43 Next
View previous topic :: View next topic
The time now is Tue Dec 02, 2008 5:32 am | All times are GMT
navigation Forum index » Programming » shell
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Function Pointer Sikandar C 3 Fri Jul 21, 2006 1:23 pm
No new posts Shortening URLs passing through a squid hierarchy Irvine, Doug - Resources Squid 0 Fri Jul 21, 2006 10:15 am
No new posts Arbitrary function with parameter darknails@gmail.com C++ 2 Fri Jul 21, 2006 9:58 am
No new posts mod_rewrite to go from http to https and back sevans@bigskypenguin.com Apache 0 Fri Jul 21, 2006 5:12 am
No new posts Is there C/C++ corresponding function in Linux for Java's... xiebopublic@gmail.com apps 4 Fri Jul 21, 2006 3:22 am

Ethical hacking tool kit | Web Advertising | Remortgages | Current Accounts | Mortgages
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.2985s ][ Queries: 16 (0.1815s) ][ GZIP on - Debug on ]