Skip to content

Commit

Permalink
Update nc check command and random string generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Tzvonimir committed Apr 2, 2024
1 parent 2fc7330 commit 330b360
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion shell/scripts/bash.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
generate_uuid() {
echo "$(date +%s)-$$-$RANDOM" | openssl sha1 | cut -d " " -f2
echo "$(date +%s)-$$-$RANDOM"
}

preexec_invoke_exec() {
Expand Down
10 changes: 7 additions & 3 deletions shell/scripts/collector.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ command_exists() {
command -v "$1" >/dev/null 2>&1
}

# Check if command exists and supports specific options
# Check if nc supports the -U flag
nc_supports_U() {
echo | nc -U "" &> /dev/null
return $?
echo | nc -U "" > /dev/null 2>&1
if [ $? -eq 0 ] || [ $? -eq 1 ]; then
return 0
else
return 1
fi
}

# Python function to communicate via socket
Expand Down
4 changes: 1 addition & 3 deletions shell/scripts/fish.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
function generate_uuid
echo (date +%s)"-"(echo %self)"-"(random)
| shasum
| cut -d " " -f1
end

function fish_preexec --on-event fish_preexec
Expand All @@ -14,4 +12,4 @@ end
function fish_postexec --on-event fish_postexec
# Send an end execution message
{.CommandScriptPath}} "end" "$LAST_COMMAND" "$PWD" "$USER" "$UUID"
end
end
2 changes: 1 addition & 1 deletion shell/scripts/zsh.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
generate_uuid() {
echo "$(date +%s)-$$-$RANDOM" | shasum | cut -d " " -f1
echo "$(date +%s)-$$-$RANDOM"
}

preexec() {
Expand Down

0 comments on commit 330b360

Please sign in to comment.