| Author |
Message |
Ed Morton *nix forums Guru
Joined: 20 Feb 2005
Posts: 1073
|
Posted: Sat Feb 19, 2005 8:46 pm Post subject:
Re: How to display the each executed line of a shell script?
|
|
|
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
|
Posted: Sat Feb 19, 2005 8:46 pm Post subject:
Re: How to display the each executed line of a shell script?
|
|
|
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
|
Posted: Sat Feb 19, 2005 8:46 pm Post subject:
Re: How to display the each executed line of a shell script?
|
|
|
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
|
Posted: Sat Feb 19, 2005 8:46 pm Post subject:
Re: How to display the each executed line of a shell script?
|
|
|
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
|
Posted: Sat Feb 19, 2005 8:46 pm Post subject:
Re: How to display the each executed line of a shell script?
|
|
|
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
|
Posted: Sat Feb 19, 2005 8:46 pm Post subject:
Re: How to display the each executed line of a shell script?
|
|
|
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
|
Posted: Sat Feb 19, 2005 8:46 pm Post subject:
Re: How to display the each executed line of a shell script?
|
|
|
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
|
Posted: Sat Feb 19, 2005 8:46 pm Post subject:
Re: How to display the each executed line of a shell script?
|
|
|
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
|
Posted: Sat Feb 19, 2005 8:46 pm Post subject:
Re: How to display the each executed line of a shell script?
|
|
|
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
|
Posted: Sat Feb 19, 2005 8:46 pm Post subject:
Re: How to display the each executed line of a shell script?
|
|
|
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
|
Posted: Sat Feb 19, 2005 8:46 pm Post subject:
Re: Wanted: GNU utility (similar to sed) to edit text files directly.
|
|
|
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
|
Posted: Sat Feb 19, 2005 8:46 pm Post subject:
Re: How to display the each executed line of a shell script?
|
|
|
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
|
Posted: Sat Feb 19, 2005 8:46 pm Post subject:
Re: Passing parameters back from a function
|
|
|
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
|
Posted: Sat Feb 19, 2005 8:46 pm Post subject:
Re: How to display the each executed line of a shell script?
|
|
|
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
|
Posted: Sat Feb 19, 2005 8:46 pm Post subject:
Re: How to display the each executed line of a shell script?
|
|
|
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 |
|
 |
|