Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to stop debug in the mid of process? Post 302871831 by bakunin on Thursday 7th of November 2013 04:33:53 AM
Old 11-07-2013
Don has it - as always - right: instead of tracing the script wholesale you should trace one (small) piece after the other. Set pairs of set -xv and set +xv and move these pairs around while debugging.

Another thing is: debugging output happens on <stderr> and you can catch this output and display it pagewise:

Code:
/your/script_with_tracing.sh 2>&1 | more

My favourite is yet to (mostly) skip tracing altogether. In most cases you can put in some diagnostic messages into your script. Suppose you have the following:

Code:
while [ $value != something ] ; do
     command1
     command2
     value=$(some_command giving some value)
     command3
done

Instead of decorating such a loop with "set +/- xv" you could also build in a diagnostic message and let it run:

Code:
while [ $value != something ] ; do
     command1
     command2

     echo "old value is $value"
     value=$(some_command giving some value)
     echo "new value is $value"
    
     command3
done

Now you will get pairs of before- and after-values and can probably find the culprit. Maybe there is another component involved, so output that too with each pass of the loop. You get the idea.

Once you found and corrected the problem you remove these lines again and start working on the next bug the same way.

Another possibility is to display commands instead of executing them. Replace any:

Code:
problematic_command $value1 $value2

with

Code:
DEBUG="echo "       # somewhere at the beginning of execution

...

$DEBUG problematic_command $value1 $value2

You can decorate several interesting commands like that. If you set DEBUG to "echo" they are not executed but displayed like they would be executed, quite similar to what you see with "set -x". Set DEBUG to "" and they are executed normally again. This way you can switch between debugging runs and normal runs easily.

I hope this helps.

bakunin
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Stop / kill the process individually

Hi , I have a situation, where I have 10 indivudal processess started by similar instance.I say similar instance because each of them being started as a new thread: Say I've following unix process running process1_ADAP process2_ADAP process3_ADAP Current scenario: Now I have SHUTDOWN... (5 Replies)
Discussion started by: braindrain
5 Replies

2. AIX

a process that never stop

Dears all i have an AIX box in which i am facing a problem with a process as below: /usr/dt/bin/dtexec -open 0 -ttprocid and each time i am killing this process with "kill -9" then it run again after a while. any ideas or solutions will be appreciated. (13 Replies)
Discussion started by: TheEngineer
13 Replies

3. Programming

Debug two process Using GDB

Hi All I know How to attach a process to beubg it .But for my application I am using client as well server.Both are two separate process .Suppose I need to debug both .How to attach both of them together .Or I have to attach them separetly . Suppose client process id is 1325 and server is... (2 Replies)
Discussion started by: mr_deb
2 Replies

4. Shell Programming and Scripting

how to stop the process that is running continously

Hi there, I have written a script to check daily process, each script is in a different directory. Now the first process is running fine, when it goes to the next directory the process doesn't executes. cd result/logs ref=month_1888.log echo $ref>> $logfile cd /max/tot/first... (3 Replies)
Discussion started by: NehaKrish
3 Replies

5. Shell Programming and Scripting

Process running? Stop it

I have this "process keepalive" script: #!/bin/bash PIDFILE=/tmp/php.pid PHPSCRIPT=/home/www/mydomain.com/subdomains/www/parser.php echo 'Checking php process from PID file' if ; then PID=`cat $PIDFILE` if ps ax | grep -v grep | grep $PID > /dev/null then echo "php process still... (4 Replies)
Discussion started by: LukasB
4 Replies

6. UNIX for Dummies Questions & Answers

Stop the process

I have the following log file running since yesterday and its consuming so much of the disk space. -rw-rw-r-- 1 dev dba 4543237120 Nov 10 09:00 load_run_file1_0.1111091224.lg How do i kill this process. I don't have any idea of stopping this. Any help would be really appreciated. ... (3 Replies)
Discussion started by: bobby1015
3 Replies

7. Shell Programming and Scripting

How to stop the process in shell scripting?

Hi all, I have tried the below code to execute. #! /bin/bash date1=`date -d "today 08:00:00" +%s` date2=`date -d "today 08:01:00" +%s` path=/home/user01/red/IDC/sample cd $path java Cspsamp 111.19.5.172 7025 rd1 rd1 "5022=Query|5026=109378|4=627|5=E:VD|5042=$date1|5049=$date2"... (5 Replies)
Discussion started by: aish11
5 Replies

8. Shell Programming and Scripting

Bash Question: HowTo Exit Script with User Input While Process is Running Mid-Loop?

Hi, I have written a script that allows me to repetitively play a music file $N times, which is specified through user input. However, if I want to exit the script before it has finished looping $N times, if I use CTRL+c, I have to CTRL+c however many times are left in order to complete the loop.... (9 Replies)
Discussion started by: hilltop_yodeler
9 Replies
AMIDI(1)						      General Commands Manual							  AMIDI(1)

NAME
amidi - read from and write to ALSA RawMIDI ports SYNOPSIS
amidi [-p port] [-s file | -S data] [-r file] [-d] [-t seconds] [-a] DESCRIPTION
amidi is a command-line utility which allows one to receive and send SysEx (system exclusive) data from/to external MIDI devices. It can also send any other MIDI commands. amidi handles only files containing raw MIDI commands, without timing information. amidi does not support Standard MIDI (.mid) files, but aplaymidi(1) and arecordmidi(1) do. OPTIONS
Use the -h, -V, -l, or -L options to display information; or use at least one of the -s, -r, -S, or -d options to specify what data to send or receive. -h, --help Help: prints a list of options. -V, --version Prints the current version. -l, --list-devices Prints a list of all hardware MIDI ports. -L, --list-rawmidis Prints all RawMIDI definitions. (used when debugging configuration files) -p, --port=name Sets the name of the ALSA RawMIDI port to use. If this is not specified, amidi uses the default port defined in the configuration file (the default for this is port 0 on card 0, which may not exist). -s, --send=filename Sends the contents of the specified file to the MIDI port. The file must contain raw MIDI commands (e.g. a .syx file); for Standard MIDI (.mid) files, use aplaymidi(1). -r, --receive=filename Writes data received from the MIDI port into the specified file. The file will contain raw MIDI commands (such as in a .syx file); to record a Standard MIDI (.mid) file, use arecordmidi(1). amidi will filter out any Active Sensing bytes (FEh), unless the -a option has been given. -S, --send-hex="..." Sends the bytes specified as hexadecimal numbers to the MIDI port. -d, --dump Prints data received from the MIDI port as hexadecimal bytes. Active Sensing bytes (FEh) will not be shown, unless the -a option has been given. This option is useful for debugging. -t, --timeout=seconds Stops receiving data when no data has been received for the specified amount of time. If this option has not been given, you must press Ctrl+C (or kill amidi) to stop receiving data. -a, --active-sensing Does not ignore Active Sensing bytes (FEh) when saving or printing received MIDI commands. EXAMPLES
amidi -p hw:0 -s my_settings.syx will send the MIDI commands in my_settings.syx to port hw:0. amidi -S 'F0 43 10 4C 00 00 7E 00 F7' sends an XG Reset to the default port. amidi -p hw:1,2 -S F0411042110C000000000074F7 -r dump.syx -t 1 sends a "Parameter Dump Request" to a GS device, saves the received parameter data to the file dump.syx, and stops after the device has finished sending data (when no data has been received for one second). amidi -p virtual -d creates a virtual RawMIDI port and prints all data sent to this port. FILES
/usr/share/alsa/alsa.conf default rawmidi definitions /etc/asound.conf system-wide rawmidi definitions ~/.asoundrc user specific rawmidi definitions SEE ALSO
aplaymidi(1) arecordmidi(1) AUTHOR
Clemens Ladisch <clemens@ladisch.de> 26 Jun 2006 AMIDI(1)
All times are GMT -4. The time now is 03:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy