duanchao4445 2018-06-28 21:18
浏览 63
已采纳

Php和bash一起生成密钥

I have this bash file which generates key and expire time :

#!/bin/bash
get_customer_url() {
  local IP=${1:-127.0.0.1}
  local SECRET=${2:-VERY_COOL_SECRET}
  local EXPIRES="$(date -d "today + 30 minutes" +%s)";
  local token="$(echo -n "${EXPIRES} VERY_COOL_SECRET" | openssl md5 -binary | openssl base64 | tr +/ -_ | tr -d =)"
  echo "/${token}/${EXPIRES}/"
}
get_customer_url

and i call it via php like this

<?php $output = shell_exec('sh generate-keys-hls.sh'); echo "$output";?>

it works fine , it generates something like this

/G8INKLc3VfDMYtQT2NTU-w/1530222035/ 

my problem is i want to put another php result in the some line like this

<?php $output = shell_exec('sh generate-keys-hls.sh'); echo "$output";?><?php echo get_post_meta($post->ID, 'file', true)?>

currently its printing the result in two lines i need it to be one just one line instead of this

/G8INKLc3VfDMYtQT2NTU-w/1530222035/ 
file.mp4.m3u8

i want it to be like this

/G8INKLc3VfDMYtQT2NTU-w/1530222035/file.mp4.m3u8

without white spaces or multiple lines !

  • 写回答

1条回答 默认 最新

  • drjun1994 2018-06-28 21:24
    关注

    Remove the whitespace around the result of shell_exec().

    echo trim($output);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 iOS绕地区网络检测
  • ¥15 python验证码滑块图像识别
  • ¥15 根据背景及设计要求撰写设计报告
  • ¥15 QT6颜色选择对话框显示不完整
  • ¥20 能提供一下思路或者代码吗
  • ¥15 用twincat控制!
  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥15 DS18B20内部ADC模数转换器