从base64解码并执行命令

Decode from base64 and execute command

我想在 Linux 框上执行命令,但我应该以 base64 格式发送命令。

如何在 Linux 命令上解码 base64 字符串,然后执行解码后的字符串?

使用base64 -d:

# 'string' variable contains a base64 encoded command
command=$(base64 -d <<< "$string"); decode_status=$?
# run the command only if decode was successful
# we shouldn't enclose $command in double quotes in this case
[[ $decode_status == 0 ]] && $command