0

All I 've found is something like python3 -m pdb myscript.py but it does not do what set -x does which executes the script and shows on terminal each line that gets executed with the actual values of the variables.

For example:

#!/bin/bash
set -x
echo "This is a foo message"
sshpass -p $2 ssh root@$1
echo "this is just argument no3 --> $3 :)"

So when you run the script with arguments you see what exactly gets done.

root@notebook:~# ./myscript.sh myserver.com mypassword bar

+ echo 'This is a foo message'
This is a foo message

+ sshpass -p mypassword ssh root@myserver.com

+ echo "this is just argument no3 --> bar :)"
this is just argument no3 --> bar :)
DimiDak
  • 4,820
  • 2
  • 26
  • 32
  • Not on-point for the question, but note that if you don't trust the user who provides the password, `sshpass -p $2 ssh root@$1` is dangerous -- if the user provides a password that contains spaces, it can run arbitrary other commands. Always quote your expansions: `sshpass -p "$2" ssh "root@$1"` – Charles Duffy Feb 04 '21 at 03:15

1 Answers1

1

yes hi, perhaps using python -m trace -t myscript.py will show you the trace you're interested in.

IronMan
  • 1,854
  • 10
  • 7
  • Dude the output of that was 1.407.752 lines (not kidding) of code... :) It seems that it goes through each line of python libraries or something. – DimiDak Feb 04 '21 at 02:30
  • yes, you might want to `grep` the output for your script name to filter out the other stuff. – IronMan Feb 04 '21 at 02:34
  • In [How to Answer](https://stackoverflow.com/help/how-to-answer), note the section _Answer Well-Asked Questions_, and therein the bullet point regarding questions that "have been asked and answered many times before". – Charles Duffy Feb 04 '21 at 03:13