LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-05-2004, 08:29 AM   #1
linuxnube
Member
 
Registered: Oct 2003
Location: US
Distribution: Fedora C1 & C2
Posts: 81

Rep: Reputation: 15
script help


I have several shell scripts which are sending errors to stderr. Is there anyway to have the line in the script echo the command to stdout as it is running in order to determine what is failing?

How does one see 'into' a running script - or can one step through a script?

Thanks!

Last edited by linuxnube; 02-05-2004 at 08:42 AM.
 
Old 02-05-2004, 09:38 AM   #2
LinuxLala
Senior Member
 
Registered: Aug 2003
Location: New Delhi, India
Distribution: Fedora 7
Posts: 1,305

Rep: Reputation: 45
I'd say that you will find better answers in the Programming forum.

Report this thread to a moderator(click on the Report this post to a moderator link on the bottom right of your post) and ask him to move the thread to the programming forum)

Cheers.
 
Old 02-05-2004, 10:43 AM   #3
/bin/bash
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 47
Normaly stderr would go to the console, so you probably have a line in the script that is sending it to /dev/null. This is common with dameons.

From the Advanced Bash-Scripting Guide.
Code:
   1>filename
      # Redirect stdout to file "filename".
   1>>filename
      # Redirect and append stdout to file "filename".
   2>filename
      # Redirect stderr to file "filename".
   2>>filename
      # Redirect and append stderr to file "filename".
   &>filename
      # Redirect both stdout and stderr to file "filename".
So look for a line like this and comment it out, then you should see the errors.
COMMAND THAT FAILS &> /dev/null
COMMAND THAT FAILS # &> /dev/null

Last edited by /bin/bash; 02-05-2004 at 10:45 AM.
 
Old 02-05-2004, 10:45 AM   #4
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Moved: User Request
 
Old 02-05-2004, 11:49 AM   #5
linuxnube
Member
 
Registered: Oct 2003
Location: US
Distribution: Fedora C1 & C2
Posts: 81

Original Poster
Rep: Reputation: 15
Actually, I am seeing the errors and not the lines that cause them. I was hoping there was a way see:

command line of script
results/error of line of script

command line of script
results/error of line of script

command line of script
results/error of line of script

Any hope?
 
Old 02-05-2004, 12:27 PM   #6
markjuggles
Member
 
Registered: Nov 2003
Location: Chicago western suburbs
Distribution: Linux Mint
Posts: 75

Rep: Reputation: 15
Seeing into a script

Hi,

Try running your script from an explicit shell using the -x option:

$ bash -x my_script

Mark
 
Old 02-05-2004, 02:49 PM   #7
linuxnube
Member
 
Registered: Oct 2003
Location: US
Distribution: Fedora C1 & C2
Posts: 81

Original Poster
Rep: Reputation: 15
Thanks - just what I was looking for.
 
  


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
Iptables (with masq) troubleshooting, very simple script attached script and logs. xinu Linux - Networking 13 11-01-2007 04:19 AM
Directory listing - Calling shell script from a CGI script seran Programming 6 08-11-2005 11:08 PM
creating shell script that executes as root regardless of who runs the script? m3kgt Linux - General 13 06-04-2004 10:23 PM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM
linux 9 and java script error - premature end of script header sibil Linux - Newbie 0 01-06-2004 04:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:16 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