1

I have a Linux shell script (test_script) that receives arguments, that are later interpreted by the same shell script and assigns the incoming arguments to some parameters. Now, is there a way to write the shell calling command to a log file as is?

Explanation:

  1. I call the test_script as follows:

    sh test_script -u test_user -d test_dir
    
  2. Within the same test_script I want to write some piece of code that can log the incoming shell calling command as is to a log file. I.e., when I open the log file, I should be able to see

    sh test_script -u test_user -d test_dir
    
jww
  • 97,681
  • 90
  • 411
  • 885
  • 2
    If you're using bash, then this is a possible duplicate of [How to get the complete calling command of a BASH script from inside the script (not just the arguments)](https://stackoverflow.com/questions/36625593/how-to-get-the-complete-calling-command-of-a-bash-script-from-inside-the-script) – Nikos C. Jun 19 '19 at 10:10
  • Possible duplicate of [Echoing the last command run in Bash?](https://stackoverflow.com/q/6109225/608639), [Bash command history update before execution of command](http://stackoverflow.com/questions/2992600/bash-command-history-update-before-execution-of-command), [Logging last Bash command to file from script](https://stackoverflow.com/q/33069648/608639), etc. – jww Jun 19 '19 at 16:19

0 Answers0