Since many people want or are asked to send some logs (for e.g. finding more info about errors), I created a few bash scripts that can help you send the logs to the internet.
rm -f log.txt              # Remove possible old logs!
log_lspci       log.txt    # Add lspci output to a log file.
log_xorg        log.txt    # Add xorg log to a log file.
log_journal     log.txt    # Add journal to a log file.
log_cmd lsusb   log.txt    # Add lsusb output to a log file.
log_file        log.txt    # Send all added logs to the internet.
rm -f log.txt              # Cleanup.
log_journal                   # Send journal to the internet.
log_file /var/log/Xorg.0.log  # Send xorg log to the internet.
# Paste output from pipe to net, and store info about this event.
local cmd="$1"     # Used only for storing info about this event.
printf "\n%s\n%s\n%s\n\n" "$sep_line" "$cmd" "$sep_line"
# Add the output of a command to the given file or to the internet.
local logfile="$2"   # If not given, output is copied to the internet.
touch "$logfile"      # Log file doesn't exist, try to create it.
_log_hide_info "$logfile"   # could be removed?
# Output goes to the internet. The returned URL tells where it can be found.
cat $logfile | _log_pipe_to_net "$cmd"
# Copy the file contents to a log file (if given) or to the internet.
local logfile="$2"   # If not given, $file contents are copied to the internet.
log_file log.txt # Send all added logs to the internet.
how it is doing this?
Each of the above commands put their stuff into the same log file log.txt.
just sends the contents of log.txt to the internet (pastebin etc.) and the URL returns.
The most complicated function is log_cmd(). It checks it arguments and determines if the user wanted to just add more stuff to the given logfile, or send the output of one command to the internet.
Then log_file sends the contents of the given log file to the internet.
The first example should now make more sense, with this explanation.
In the second example (user visible) log files are not used at all. The two separate example commands just directly send their stuff to the internet.
All of these commands (or functions) work together. Always when sending stuff to the internet, the send event is recorded to a file in user's $HOME directory.
Then user may later see what events she/he has done before.
There could be a function like log_all() that would combine all the other functions and simply send the whole log stuff.
Do you think it would be better that way?
how exactly i can execute differend commands and options?
All functions put their output to the "sink".
In a function call, the user gives the input (a command string or a file name), and optionally the log file, if user wants that to be the sink.
There are two basic functions that handle most of the work.
command: A command string, e.g. "lspci -vnn", its output goes to the sink.
logfile: Name of the log file (optional).
inputfile: File to be copied to the sink.
The two log_cmd commands have the same input, but the first has internet as the sink. The second has a log file as the sink.
Also, the two log_file have the same input, but the output goes to the internet with the first, and to the log file with the second.
Then there are a few "helper" functions, which take only one parameter (the optional log file). And again, if the log file is not given, the output goes directly to the internet instead of a log file.
log_journal - Puts the output of a "journalctl -b -0" command to the sink.
log_xorg - Copies the contents of file /var/log/Xorg.0.log to the sink.
This allows you to check later what you have sent to the internet.
Then a bit more advanced usage.
log_cmd "journalctl -b -0 -r --output=short-full"
The first log_cmd call sends the output directly to the internet.
The second log_cmd call puts the output to a log file, and log_file can then be used for sending it to the internet.
The commands also automatically hide (by overwriting) some of your identifying information, such as user name and the host name.
Many users (including me) may appreciate also this feature.
Now the previous post may seem something like "too long, didn't read".
But actually, the usage of these functions is really simple.
i want to ask simple how to use the script. what i have to type into the terminal?
First you need to save the script into a file, for example ~/logs.bash, then run source ~/logs.bash so that you have the commands available.
Alternatively, copy the script contents to the end of your ~/.bashrc file and after running source ~/.bashrc you'll have the commands at your disposal.
Then you can run the commands/functions as in the examples above.
sends that file to the internet to some pastebin service, and shows the URL where it is saved.
$ log_cmd "journalctl -b -0 -r --output=short-full"
But anyway, did you notice that your user name and host name have been overwritten in the pastebin link?