Visualize execution of scripts
I have a script that always runs on the Raspberry Pi.
I defined with sudo nano /etc/rc.local
so that they turn even after a reboot or a power failure.
My question is how can visualize the execution of my scrpits after rebooting or power failure especially that there are "print" (because the execution becomes in the background).
boot script debug
New contributor
add a comment |
I have a script that always runs on the Raspberry Pi.
I defined with sudo nano /etc/rc.local
so that they turn even after a reboot or a power failure.
My question is how can visualize the execution of my scrpits after rebooting or power failure especially that there are "print" (because the execution becomes in the background).
boot script debug
New contributor
You might be looking for Bootchart. See e.g. the answers to this question: raspberrypi.stackexchange.com/questions/78099/…
– Piskvor
2 days ago
Do you want to catch prited data? If yes, you can usescreen
ortmux
and run command inside it or put printed dats to the file using>
.
– Matej
2 days ago
do you want an animated GIF( en.wikipedia.org/wiki/GIF )?
– user2497
2 days ago
How do you want the visualization to appear? On the command line, in a graphical GUI, a LED connected to a GPIO or a web page ?
– MatsK
yesterday
The swirling dash is a godlike version of progress meters. All you need is a shell, ‘/‘, ‘’, and 0x0d controlchar. Other versions exist (on my system at least), in which ascii drawings of mammal genitalia (so it’s not necessary to remove my comment, over-zealous moderators!) is animated to give the impression that progress is made.
– user2497
yesterday
add a comment |
I have a script that always runs on the Raspberry Pi.
I defined with sudo nano /etc/rc.local
so that they turn even after a reboot or a power failure.
My question is how can visualize the execution of my scrpits after rebooting or power failure especially that there are "print" (because the execution becomes in the background).
boot script debug
New contributor
I have a script that always runs on the Raspberry Pi.
I defined with sudo nano /etc/rc.local
so that they turn even after a reboot or a power failure.
My question is how can visualize the execution of my scrpits after rebooting or power failure especially that there are "print" (because the execution becomes in the background).
boot script debug
boot script debug
New contributor
New contributor
edited 2 days ago
F1Linux
192110
192110
New contributor
asked 2 days ago
AmélieAmélie
161
161
New contributor
New contributor
You might be looking for Bootchart. See e.g. the answers to this question: raspberrypi.stackexchange.com/questions/78099/…
– Piskvor
2 days ago
Do you want to catch prited data? If yes, you can usescreen
ortmux
and run command inside it or put printed dats to the file using>
.
– Matej
2 days ago
do you want an animated GIF( en.wikipedia.org/wiki/GIF )?
– user2497
2 days ago
How do you want the visualization to appear? On the command line, in a graphical GUI, a LED connected to a GPIO or a web page ?
– MatsK
yesterday
The swirling dash is a godlike version of progress meters. All you need is a shell, ‘/‘, ‘’, and 0x0d controlchar. Other versions exist (on my system at least), in which ascii drawings of mammal genitalia (so it’s not necessary to remove my comment, over-zealous moderators!) is animated to give the impression that progress is made.
– user2497
yesterday
add a comment |
You might be looking for Bootchart. See e.g. the answers to this question: raspberrypi.stackexchange.com/questions/78099/…
– Piskvor
2 days ago
Do you want to catch prited data? If yes, you can usescreen
ortmux
and run command inside it or put printed dats to the file using>
.
– Matej
2 days ago
do you want an animated GIF( en.wikipedia.org/wiki/GIF )?
– user2497
2 days ago
How do you want the visualization to appear? On the command line, in a graphical GUI, a LED connected to a GPIO or a web page ?
– MatsK
yesterday
The swirling dash is a godlike version of progress meters. All you need is a shell, ‘/‘, ‘’, and 0x0d controlchar. Other versions exist (on my system at least), in which ascii drawings of mammal genitalia (so it’s not necessary to remove my comment, over-zealous moderators!) is animated to give the impression that progress is made.
– user2497
yesterday
You might be looking for Bootchart. See e.g. the answers to this question: raspberrypi.stackexchange.com/questions/78099/…
– Piskvor
2 days ago
You might be looking for Bootchart. See e.g. the answers to this question: raspberrypi.stackexchange.com/questions/78099/…
– Piskvor
2 days ago
Do you want to catch prited data? If yes, you can use
screen
or tmux
and run command inside it or put printed dats to the file using >
.– Matej
2 days ago
Do you want to catch prited data? If yes, you can use
screen
or tmux
and run command inside it or put printed dats to the file using >
.– Matej
2 days ago
do you want an animated GIF( en.wikipedia.org/wiki/GIF )?
– user2497
2 days ago
do you want an animated GIF( en.wikipedia.org/wiki/GIF )?
– user2497
2 days ago
How do you want the visualization to appear? On the command line, in a graphical GUI, a LED connected to a GPIO or a web page ?
– MatsK
yesterday
How do you want the visualization to appear? On the command line, in a graphical GUI, a LED connected to a GPIO or a web page ?
– MatsK
yesterday
The swirling dash is a godlike version of progress meters. All you need is a shell, ‘/‘, ‘’, and 0x0d controlchar. Other versions exist (on my system at least), in which ascii drawings of mammal genitalia (so it’s not necessary to remove my comment, over-zealous moderators!) is animated to give the impression that progress is made.
– user2497
yesterday
The swirling dash is a godlike version of progress meters. All you need is a shell, ‘/‘, ‘’, and 0x0d controlchar. Other versions exist (on my system at least), in which ascii drawings of mammal genitalia (so it’s not necessary to remove my comment, over-zealous moderators!) is animated to give the impression that progress is made.
– user2497
yesterday
add a comment |
2 Answers
2
active
oldest
votes
Redirect output and errors to a file:
myscript.sh >> /home/pi/log.txt 2>&1 &
Mind the last&
, it sends the script execution to the background (you may don't want to).
– GramThanos
2 days ago
How does this visualize the execution of a script?
– Ingo
2 days ago
View the log.txt file or repeatedly 'tail log.txt'
– CoderMike
2 days ago
What is your understanding of visualize? Looking at scrolling text? For me it's unclear what the OP means. Is it a bootchart, catching printed data or an animated gif, as others already asked?
– Ingo
2 days ago
My understanding is too view the output of the scripts - usually when something is not working.
– CoderMike
2 days ago
add a comment |
Redirect output of set -x
to a log to capture any potential errors as script executed.
varFD is an arbitrary variable name (you could call it something else if you wish) and used here to assign the next unused File Descriptor to redirect output to the log
In your script under the SheBang add the following:
#!/bin/bash
exec {varFD}>/home/pi/yourScript.log
BASH_XTRACEFD=$varFD
set -x
This will give you granular feedback on how the script operated, including how variables DID, or worse, DID NOT expand. Specimen output from one of my scripts from the log where it was captured:
+ sleep 10
++ readlink -f /home/pi/open-ipcamera-scripts/email-camera-address.sh
+ SCRIPTLOCATION=/home/pi/open-ipcamera-scripts/email-camera-address.sh
++ sudo sed -n 's/sysLocation.[[:space:]]*//p' /etc/snmp/snmpd.conf
+ CAMERALOCATION='Office Door'
++ sudo sed -n 's/sysContact.[[:space:]]*//p' /etc/snmp/snmpd.conf
+ SYSCONTACT=joe.blogs@gmail.com
++ ip addr list
++ grep inet
++ awk FNR==2
++ grep -oE '[1-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}'
+ CAMERAIPV4=192.168.1.22
++ cut -d / -f1
++ grep -P '^(?!fe80)[[:alnum:]]{4}:.*/64'
++ awk '{print $2}'
++ ip -6 addr
+ CAMERAIPV6=
+ msmtp joe.bloggs@gmail.com
++ echo 192.168.1.22
++ hostname
+ echo -e 'Subject: IP of Camera: 192.168.1.22rnrnIP Address of Office Door Camera pi3Bplus-camera1.example.com is: 192.168.1.22 / '''n''' Script sending this email: /home/pi/open-ipcamera-scripts/email-camera-address.sh'
HTH-
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("schematics", function () {
StackExchange.schematics.init();
});
}, "cicuitlab");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "447"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Amélie is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fraspberrypi.stackexchange.com%2fquestions%2f94904%2fvisualize-execution-of-scripts%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Redirect output and errors to a file:
myscript.sh >> /home/pi/log.txt 2>&1 &
Mind the last&
, it sends the script execution to the background (you may don't want to).
– GramThanos
2 days ago
How does this visualize the execution of a script?
– Ingo
2 days ago
View the log.txt file or repeatedly 'tail log.txt'
– CoderMike
2 days ago
What is your understanding of visualize? Looking at scrolling text? For me it's unclear what the OP means. Is it a bootchart, catching printed data or an animated gif, as others already asked?
– Ingo
2 days ago
My understanding is too view the output of the scripts - usually when something is not working.
– CoderMike
2 days ago
add a comment |
Redirect output and errors to a file:
myscript.sh >> /home/pi/log.txt 2>&1 &
Mind the last&
, it sends the script execution to the background (you may don't want to).
– GramThanos
2 days ago
How does this visualize the execution of a script?
– Ingo
2 days ago
View the log.txt file or repeatedly 'tail log.txt'
– CoderMike
2 days ago
What is your understanding of visualize? Looking at scrolling text? For me it's unclear what the OP means. Is it a bootchart, catching printed data or an animated gif, as others already asked?
– Ingo
2 days ago
My understanding is too view the output of the scripts - usually when something is not working.
– CoderMike
2 days ago
add a comment |
Redirect output and errors to a file:
myscript.sh >> /home/pi/log.txt 2>&1 &
Redirect output and errors to a file:
myscript.sh >> /home/pi/log.txt 2>&1 &
answered 2 days ago
CoderMikeCoderMike
2,4521513
2,4521513
Mind the last&
, it sends the script execution to the background (you may don't want to).
– GramThanos
2 days ago
How does this visualize the execution of a script?
– Ingo
2 days ago
View the log.txt file or repeatedly 'tail log.txt'
– CoderMike
2 days ago
What is your understanding of visualize? Looking at scrolling text? For me it's unclear what the OP means. Is it a bootchart, catching printed data or an animated gif, as others already asked?
– Ingo
2 days ago
My understanding is too view the output of the scripts - usually when something is not working.
– CoderMike
2 days ago
add a comment |
Mind the last&
, it sends the script execution to the background (you may don't want to).
– GramThanos
2 days ago
How does this visualize the execution of a script?
– Ingo
2 days ago
View the log.txt file or repeatedly 'tail log.txt'
– CoderMike
2 days ago
What is your understanding of visualize? Looking at scrolling text? For me it's unclear what the OP means. Is it a bootchart, catching printed data or an animated gif, as others already asked?
– Ingo
2 days ago
My understanding is too view the output of the scripts - usually when something is not working.
– CoderMike
2 days ago
Mind the last
&
, it sends the script execution to the background (you may don't want to).– GramThanos
2 days ago
Mind the last
&
, it sends the script execution to the background (you may don't want to).– GramThanos
2 days ago
How does this visualize the execution of a script?
– Ingo
2 days ago
How does this visualize the execution of a script?
– Ingo
2 days ago
View the log.txt file or repeatedly 'tail log.txt'
– CoderMike
2 days ago
View the log.txt file or repeatedly 'tail log.txt'
– CoderMike
2 days ago
What is your understanding of visualize? Looking at scrolling text? For me it's unclear what the OP means. Is it a bootchart, catching printed data or an animated gif, as others already asked?
– Ingo
2 days ago
What is your understanding of visualize? Looking at scrolling text? For me it's unclear what the OP means. Is it a bootchart, catching printed data or an animated gif, as others already asked?
– Ingo
2 days ago
My understanding is too view the output of the scripts - usually when something is not working.
– CoderMike
2 days ago
My understanding is too view the output of the scripts - usually when something is not working.
– CoderMike
2 days ago
add a comment |
Redirect output of set -x
to a log to capture any potential errors as script executed.
varFD is an arbitrary variable name (you could call it something else if you wish) and used here to assign the next unused File Descriptor to redirect output to the log
In your script under the SheBang add the following:
#!/bin/bash
exec {varFD}>/home/pi/yourScript.log
BASH_XTRACEFD=$varFD
set -x
This will give you granular feedback on how the script operated, including how variables DID, or worse, DID NOT expand. Specimen output from one of my scripts from the log where it was captured:
+ sleep 10
++ readlink -f /home/pi/open-ipcamera-scripts/email-camera-address.sh
+ SCRIPTLOCATION=/home/pi/open-ipcamera-scripts/email-camera-address.sh
++ sudo sed -n 's/sysLocation.[[:space:]]*//p' /etc/snmp/snmpd.conf
+ CAMERALOCATION='Office Door'
++ sudo sed -n 's/sysContact.[[:space:]]*//p' /etc/snmp/snmpd.conf
+ SYSCONTACT=joe.blogs@gmail.com
++ ip addr list
++ grep inet
++ awk FNR==2
++ grep -oE '[1-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}'
+ CAMERAIPV4=192.168.1.22
++ cut -d / -f1
++ grep -P '^(?!fe80)[[:alnum:]]{4}:.*/64'
++ awk '{print $2}'
++ ip -6 addr
+ CAMERAIPV6=
+ msmtp joe.bloggs@gmail.com
++ echo 192.168.1.22
++ hostname
+ echo -e 'Subject: IP of Camera: 192.168.1.22rnrnIP Address of Office Door Camera pi3Bplus-camera1.example.com is: 192.168.1.22 / '''n''' Script sending this email: /home/pi/open-ipcamera-scripts/email-camera-address.sh'
HTH-
add a comment |
Redirect output of set -x
to a log to capture any potential errors as script executed.
varFD is an arbitrary variable name (you could call it something else if you wish) and used here to assign the next unused File Descriptor to redirect output to the log
In your script under the SheBang add the following:
#!/bin/bash
exec {varFD}>/home/pi/yourScript.log
BASH_XTRACEFD=$varFD
set -x
This will give you granular feedback on how the script operated, including how variables DID, or worse, DID NOT expand. Specimen output from one of my scripts from the log where it was captured:
+ sleep 10
++ readlink -f /home/pi/open-ipcamera-scripts/email-camera-address.sh
+ SCRIPTLOCATION=/home/pi/open-ipcamera-scripts/email-camera-address.sh
++ sudo sed -n 's/sysLocation.[[:space:]]*//p' /etc/snmp/snmpd.conf
+ CAMERALOCATION='Office Door'
++ sudo sed -n 's/sysContact.[[:space:]]*//p' /etc/snmp/snmpd.conf
+ SYSCONTACT=joe.blogs@gmail.com
++ ip addr list
++ grep inet
++ awk FNR==2
++ grep -oE '[1-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}'
+ CAMERAIPV4=192.168.1.22
++ cut -d / -f1
++ grep -P '^(?!fe80)[[:alnum:]]{4}:.*/64'
++ awk '{print $2}'
++ ip -6 addr
+ CAMERAIPV6=
+ msmtp joe.bloggs@gmail.com
++ echo 192.168.1.22
++ hostname
+ echo -e 'Subject: IP of Camera: 192.168.1.22rnrnIP Address of Office Door Camera pi3Bplus-camera1.example.com is: 192.168.1.22 / '''n''' Script sending this email: /home/pi/open-ipcamera-scripts/email-camera-address.sh'
HTH-
add a comment |
Redirect output of set -x
to a log to capture any potential errors as script executed.
varFD is an arbitrary variable name (you could call it something else if you wish) and used here to assign the next unused File Descriptor to redirect output to the log
In your script under the SheBang add the following:
#!/bin/bash
exec {varFD}>/home/pi/yourScript.log
BASH_XTRACEFD=$varFD
set -x
This will give you granular feedback on how the script operated, including how variables DID, or worse, DID NOT expand. Specimen output from one of my scripts from the log where it was captured:
+ sleep 10
++ readlink -f /home/pi/open-ipcamera-scripts/email-camera-address.sh
+ SCRIPTLOCATION=/home/pi/open-ipcamera-scripts/email-camera-address.sh
++ sudo sed -n 's/sysLocation.[[:space:]]*//p' /etc/snmp/snmpd.conf
+ CAMERALOCATION='Office Door'
++ sudo sed -n 's/sysContact.[[:space:]]*//p' /etc/snmp/snmpd.conf
+ SYSCONTACT=joe.blogs@gmail.com
++ ip addr list
++ grep inet
++ awk FNR==2
++ grep -oE '[1-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}'
+ CAMERAIPV4=192.168.1.22
++ cut -d / -f1
++ grep -P '^(?!fe80)[[:alnum:]]{4}:.*/64'
++ awk '{print $2}'
++ ip -6 addr
+ CAMERAIPV6=
+ msmtp joe.bloggs@gmail.com
++ echo 192.168.1.22
++ hostname
+ echo -e 'Subject: IP of Camera: 192.168.1.22rnrnIP Address of Office Door Camera pi3Bplus-camera1.example.com is: 192.168.1.22 / '''n''' Script sending this email: /home/pi/open-ipcamera-scripts/email-camera-address.sh'
HTH-
Redirect output of set -x
to a log to capture any potential errors as script executed.
varFD is an arbitrary variable name (you could call it something else if you wish) and used here to assign the next unused File Descriptor to redirect output to the log
In your script under the SheBang add the following:
#!/bin/bash
exec {varFD}>/home/pi/yourScript.log
BASH_XTRACEFD=$varFD
set -x
This will give you granular feedback on how the script operated, including how variables DID, or worse, DID NOT expand. Specimen output from one of my scripts from the log where it was captured:
+ sleep 10
++ readlink -f /home/pi/open-ipcamera-scripts/email-camera-address.sh
+ SCRIPTLOCATION=/home/pi/open-ipcamera-scripts/email-camera-address.sh
++ sudo sed -n 's/sysLocation.[[:space:]]*//p' /etc/snmp/snmpd.conf
+ CAMERALOCATION='Office Door'
++ sudo sed -n 's/sysContact.[[:space:]]*//p' /etc/snmp/snmpd.conf
+ SYSCONTACT=joe.blogs@gmail.com
++ ip addr list
++ grep inet
++ awk FNR==2
++ grep -oE '[1-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}'
+ CAMERAIPV4=192.168.1.22
++ cut -d / -f1
++ grep -P '^(?!fe80)[[:alnum:]]{4}:.*/64'
++ awk '{print $2}'
++ ip -6 addr
+ CAMERAIPV6=
+ msmtp joe.bloggs@gmail.com
++ echo 192.168.1.22
++ hostname
+ echo -e 'Subject: IP of Camera: 192.168.1.22rnrnIP Address of Office Door Camera pi3Bplus-camera1.example.com is: 192.168.1.22 / '''n''' Script sending this email: /home/pi/open-ipcamera-scripts/email-camera-address.sh'
HTH-
edited 2 days ago
answered 2 days ago
F1LinuxF1Linux
192110
192110
add a comment |
add a comment |
Amélie is a new contributor. Be nice, and check out our Code of Conduct.
Amélie is a new contributor. Be nice, and check out our Code of Conduct.
Amélie is a new contributor. Be nice, and check out our Code of Conduct.
Amélie is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Raspberry Pi Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fraspberrypi.stackexchange.com%2fquestions%2f94904%2fvisualize-execution-of-scripts%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You might be looking for Bootchart. See e.g. the answers to this question: raspberrypi.stackexchange.com/questions/78099/…
– Piskvor
2 days ago
Do you want to catch prited data? If yes, you can use
screen
ortmux
and run command inside it or put printed dats to the file using>
.– Matej
2 days ago
do you want an animated GIF( en.wikipedia.org/wiki/GIF )?
– user2497
2 days ago
How do you want the visualization to appear? On the command line, in a graphical GUI, a LED connected to a GPIO or a web page ?
– MatsK
yesterday
The swirling dash is a godlike version of progress meters. All you need is a shell, ‘/‘, ‘’, and 0x0d controlchar. Other versions exist (on my system at least), in which ascii drawings of mammal genitalia (so it’s not necessary to remove my comment, over-zealous moderators!) is animated to give the impression that progress is made.
– user2497
yesterday