Sponsored Content
Full Discussion: Debug script
Operating Systems Linux Ubuntu Debug script Post 303033228 by Don Cragun on Tuesday 2nd of April 2019 12:53:50 AM
Old 04-02-2019
Quote:
Originally Posted by drew77
How can I debug this script?

I want to know what it is doing or not doing?

Code:
#!/bin/bash
#
# 
if [ "${1}" = "pre" ]; then
  # Do the thing you want before suspend here
  echo "we are suspending." > /tmp/systemd_suspend_test.txt
elif [ "${1}" = "post" ]; then
  # Do the thing you want after resume here
  echo "and we are back from being suspended" >> /tmp/systemd_suspend_test.txt
  #/usr/bin/gxmessage -fg red -font  'sans 30' -timeout 3  ' Computer has now resumed from suspend state.'
fi

Given that we have no access to your system and can't see any diagnostic messages produced while your script is running, that you have not said anything about what you think might not be working in your script, and have not told us what appears in the file named /tmp/systemd_suspend_test.txt after you run your script; I find it difficult to suggest what you might do differently to debug your code.

I guess one might ask why you're throwing away all of the debugging data you have collected whenever your script is invoked with the first operand set to pre?

I guess one might ask why you don't include any timestamps in your debugging output?

I guess one might ask why you don't include a set -vx command at the start of your script and save the diagnostic information that would produce in a log file?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Debug an Awk Script

I would like to extract the following fields from the text file attached. I copied the contents from a pdf file and pasted them into the text file so I can use awk to extract them. The layout is as listed below. name1,name2,name3,name4,Title,designation,nationality,dob, national ... (1 Reply)
Discussion started by: mboro
1 Replies

2. Shell Programming and Scripting

How to debug the awk script

Hi, How can I debug an awk script? I know that set -x can be used to debug a script. But this will not suite for awk scripts. Can anyone help me? Thanks in advance, Chella (2 Replies)
Discussion started by: chella
2 Replies

3. Shell Programming and Scripting

debug this script

echo "input time in hhmmss" read $st h=`echo $st | cut -c1-2` min=`echo $st | cut -c3-4` s=`echo $st | cut -c5-6` echo "input time in hhmmss" read $end h1=`echo $end | cut -c1-2` min1=`echo $end | cut -c3-4` s1=`echo $end | cut -c5-6` x= `expr $h /* 60 + $min` y= `expr $h1 /* 60 +... (8 Replies)
Discussion started by: abhishek27
8 Replies

4. UNIX for Advanced & Expert Users

How can debug our UNIX shell script?

Hi all, i have two simple questions here... 1. i want to know that how to debug the UNIX shell script? 2. is there any way to handling the exception in UNIX shell script like oracle exception handling? Please provide me those details it would be great help/ Thanks and Regards, MPS... (3 Replies)
Discussion started by: psiva_arul
3 Replies

5. Shell Programming and Scripting

If condition error-please debug my script

Hi All, I have a script which is based on calculating current time The script looks like this: whenever i try to run the script it gives me error:Please advice wherther i have made mistake with if condition or with for loop?? The code : set -x #!/usr/bin/ksh set -x... (7 Replies)
Discussion started by: usha rao
7 Replies

6. Shell Programming and Scripting

Problem with the script, help me debug

Hi, When i run the script ./script.sh sun, this give me no output, it should give me the list of file. If i run the script without the argument it should send me echo inside usage(). What is the problem? please help -Adsi #!/bin/sh ROOT_PATH=/net/icebox/vol/local_images/spins... (2 Replies)
Discussion started by: asirohi
2 Replies

7. Shell Programming and Scripting

Help with debug the script

Hi, I have this script, searches and sets variables, then searches and sets more variables from multiple files. I'd need to debug it a bit. #!/bin/bash egrep $1 `find | grep MAGT` >/tmp/resRA-$$ thread=`sed -n '/{0x/ {s/^.*{0x\(*\).*/\1/p;q}' /tmp/resRA-$$` tag=`sed -n '/Tag=/... (5 Replies)
Discussion started by: Vitoriung
5 Replies

8. Shell Programming and Scripting

Cant debug shell script

Hi I am relatively new in shell scripting Below is the code which i developed but for some reason, it keeps giving me error: /apps/bss/BatchProg/at1/batch/scripts/ksh/TBATLC02.ksh: syntax error at line 41 : `then' unmatched #!/usr/bin/ksh... (4 Replies)
Discussion started by: scripting_newbe
4 Replies

9. Shell Programming and Scripting

Debug script already running

Hello, is it possible to debug a script that is already running "on-demand"? Somehow a command like "set -x" but once you've executed the script. And another one to disable debugging? Thank you (0 Replies)
Discussion started by: asanchez
0 Replies

10. Shell Programming and Scripting

Debug perl script

Hi, I am trying to get squid up and running using a redirector process, and every time I try to load a web page, squid fails miserably. Can some one with perl and squid knowledge take a look at these codes and tell if something is wrong here. #!/usr/bin/perl # $| = 1; @endings = qw/... (0 Replies)
Discussion started by: jamie_123
0 Replies
HIBERNATE(8)															      HIBERNATE(8)

NAME
hibernate - save your computer's state to disk, and then switch it off SYNOPSIS
hibernate [OPTION]... DESCRIPTION
The hibernate script (or "suspend script") is used to invoke the Linux kernel's Hibernation functionality. When you hibernate your machine, the contents of your computer's memory will be saved to disc, and your computer will switch off. When you switch it back on again, it will resume exactly as it was when you hibernated. This script is designed for TuxOnIce, which is not yet included in the main kernel tree and must be downloaded from the TuxOnIce web site at http://www.tuxonice.net/, but can also utilise the vanilla kernel interfaces for swsusp or pmdisk (through /proc/acpi/sleep or /sys/power/state). Instructions on setting up the kernel can also be found on that web site. The hibernate script takes care of the user-space side of the suspend, including unloading and reloading drivers which don't suspend prop- erly, setting the system clock after resuming, taking down and bringing up network interfaces and various other hacks that may be required on some hardware. By default, all it does is restore the system clock after suspending; see hibernate.conf(5) for information on configur- ing the rest of its functionality. If the hibernate script is invoked with a name of the form hibernate-foo then it will use the configuration file /etc/hibernate/foo.conf instead of the default. The hibernate script accepts the following command-line options: OPTIONS
-h, --help Shows this help screen. --version Shows the Hibernate Script version. -f, --force Ignore errors and suspend anyway. -k, --kill Kill processes if needed, in order to suspend. -v<n>, --verbosity=<n> Change verbosity level (0 = errors only, 3 = verbose, 4 = debug) -F<file>, --config-file=<file> Use the given configuration file instead of the default () --dry-run Don't actually do anything. -g, --restore-grub Restores the grub menu to normal (use if a resume was not completed successfully) and exits the script. A suspend is not performed. --lock-console-as <username> Uses vlock to lock the entire system after resuming, requirng you to enter the password for the given user to unlock it. This overrides any username given in the configuration file. (Requires vlock) -n, --no-suspend Disables actually suspending the system. This is useful for testing the hibernate script itself. -r[0|1], --reboot[=<0|1>] (requires UseTuxOnIce on) If 0 is specified, disables rebooting after writing the image, regardless of the Reboot option in the configuration file. If 1 or omitted, will force a reboot after writing the image. --bug-report (requires UseTuxOnIce on) Gathers a bunch of information about your machine and writes it to standard output. Please attach this information along with any bug reports to the TuxOnIce mailing list. EXIT CODES
The exit codes returned by the hibernate script are currently as follows: 0 Hibernation was completed successfully. 2 Hibernation was aborted due to errors from some part of the script. (eg, modules not unloading, devices or filesystems in use). 3 Hibernate script was aborted by user with Ctrl+C. (This does not mean the suspend was aborted by a user by pressing Escape). 4 Hibernation was aborted by a kernel problem (hibernate.log and dmesg should indicate why), or the user aborted the suspend with the Escape key. FILES
/etc/hibernate/hibernate.conf Contains options which influence the hibernate script's behaviour. See hibernate.conf(5) for more information. /etc/hibernate/scriptlets.d/ /usr/share/hibernate/scriptlets.d/ /usr/local/share/hibernate/scriptlets.d/ These directories contains "scriptlets" that provide functionality when suspending and resuming. See the SCRIPTLET-API file included with the distribution (which can be found in /usr/share/doc/hibernate on Debian systems) for information on how these work. BUGS
Probably lots! If you have problems with the hibernate script or TuxOnIce, the best place to ask is on the mailing list - tuxonice-users@lists.tuxon- ice.net. You will need to subscribe to post. See http://www.tuxonice.net/lists for details. If the suspend process itself crashes (while "Writing caches", "Reading caches", or "Copying original kernel back", etc), then the problem lies with TuxOnIce itself. See the FAQ at http://www.tuxonice.net/ for help on debugging. AUTHOR
This script was written by Bernard Blackham, with contributions from: o Carsten Rietzschel (modules, bootsplash and grub scriptlets. many ideas and bugfixes) o Cameron Patrick (many bugfixes and ideas, man page and Debian packaging) SEE ALSO
hibernate.conf(5) Linux Hibernation May 2012 HIBERNATE(8)
All times are GMT -4. The time now is 06:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy