Home > Blockchain >  BASH SCRIPT output doesn't export in file
BASH SCRIPT output doesn't export in file

Time:11-29

i just stuck with my self coded application calling ws command (web socket) and i'm trying to export the output. Also i want to exit wscat when it's finished after sometime of input from API from the JSON backend devlopment

#!/bin/bash
while getopts a:c: flag
do
    case "${flag}" in
        a) accesskey=${OPTARG};;
    c) clientnodeid=${OPTARG};;     
    esac
done
master="wscat -c ws://localhost:8091/ws/callback -H accessKey:$accesskey -H clientNodeId:$clientnodeid"
sleep 15
eval $master
final=$(eval echo "$master")
echo $final >>logfile.log
ps -ef | grep wscat | grep -v grep | awk '{print $2}' | xargs kill
#curl -X POST --data "$final" -k "https://localhost:7460/activate" -H "accept: application/json" -H "accessKey:$accesskey" -H "clientNodeId:$clientnodeid" -H "Content-Type: application/json" -H "callbackRequested:true"
exit 

I want to call then output from wscat to sent over curl When i run the script manually it got success but when i call it from another application (java) it's it running but not generating log.

With all words, i want to export $final to text file and that text file i should import it to --data of curl calling

CodePudding user response:

Fixed based on @Barmar's comment:

You're overcomplicating this with all those variables. Just do

eval "$master" >> logfile.log
  • Related