mitreac / b575f19

UM DCMB BIOINF 575 Fall 2019 class repo
BSD 3-Clause "New" or "Revised" License
9 stars 6 forks source link

Having issues saving the history for the bash game #4

Open jesuscastor opened 5 years ago

jesuscastor commented 5 years ago

Instructions


Question (continued)

I am having issues recording the command history during the bash game. I could not call any commands during the game, and if I exit or finish the game the history command will not show the command input in the game. It will only show the command I used to start the game "bash hw1.sh".

I am leaning more towards finding a way to activate command tracking in interactive shell scripts but I am not sure if there is an easier way to approach this.

Paste your code in this code block (if needed)


351  bash  hw1.sh
  352  hw1.sh
  353  bash hw1.sh
  354  man set
  355  set | less
  356  set | history
  357  set -o | history
  358  set -o | history | less
  359  jesusac@dcmb-classroom-jesusac:~/BIOINF_575$
  360  clear
  361  history
jesusac@dcmb-classroom-jesusac:~/BIOINF_575$ !302
bash  hw1.sh

--MENU--
Level 1: Test basic comands
Level 2: Test pipe
Level 3: Solving a problem
Level 4: Fun exercise
Level q: Exit

Choose the level (1,2,3,4 or q): q

Bye!
jesusac@dcmb-classroom-jesusac:~/BIOINF_575$ set -o history
jesusac@dcmb-classroom-jesusac:~/BIOINF_575$ !302
bash  hw1.sh

--MENU--
Level 1: Test basic comands
Level 2: Test pipe
Level 3: Solving a problem
Level 4: Fun exercise
Level q: Exit

Choose the level (1,2,3,4 or q): q

Bye!

---

![history](https://user-images.githubusercontent.com/55095732/65391943-19f8f380-dd3d-11e9-96a9-2de8c5b4e50c.jpg)

# What do you need?
I might need to activate command tracking in interactive shell scripts or expand the history of a line to show the commands used in shell.

# What have you done?
 I've tried calling the command per line (which only triggers the shell script), cutting the set of command lines in the history, and using the set -o command. Some websites recommended this command to activate history recording in shell but further reading illustrated that this command is only meant to turn on and off the history command. 

# Checklist
Replace the space in between the brackets with an X
* [ ] Identified what you already have available to address this question
* [ ] Identified what you need to reach an acceptable answer
* [ ] Shown what you have done up to this point
    * [ ] A hypothesis if this is a general question
    * [ ] Your code, error messages, and output if this is a coding question
mitreac commented 5 years ago

The set -o command and history command should be called in the script to record and display the history. In the files on canvas under the Linux and git folder there is now a hw1_hist.sh script that will display the input you provided in the game to the console after you quit the game and through the game it will save that input in a local_hist.txt file.