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);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮