Quantcast
Channel: Howto pass a mixed string from php through a pipe to a bash script - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by crst for Howto pass a mixed string from php through a pipe to a bash script

$
0
0

I don't know PHP but bash should do something like one post of the top-related on the right side:

#!/usr/bin/env bash

declare    line  ; line=
declare -a line_ ; line_=()

while IFS= read -r line ; do
    line_+=( "${line}" )
done < /dev/stdin

printf "%s\n" "${line_[@]}"

Assumed the script's name is some_script.sh you can do

% echo '&Ω↑ẞÐĦØđ¢ø' | bash some_script.sh
&Ω↑ẞÐĦØđ¢ø

while IFS= read -r line is explained here: Bash, read line by line from file, with IFS and on the bash wiki

  • IFS is set to the empty string to prevent read from stripping leading and trailing whitespace from each line. – Richard Hansen
  • -r raw input - disables interpretion of backslash escapes and line-continuation in the read data

Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>