Run a string as a command within a Bash script

前端 未结 8 907
清歌不尽
清歌不尽 2020-12-07 09:08

I have a Bash script that builds a string to run as a command

Script:

#! /bin/bash

matchdir=\"/home/joao/robocup/runner_workdir/mat         


        
8条回答
  •  执笔经年
    2020-12-07 09:40

    To see all commands that are being executed by the script, add the -x flag to your shabang line, and execute the command normally:

    #! /bin/bash -x
    
    matchdir="/home/joao/robocup/runner_workdir/matches/testmatch/"
    
    teamAComm="`pwd`/a.sh"
    teamBComm="`pwd`/b.sh"
    include="`pwd`/server_official.conf"
    serverbin='/usr/local/bin/rcssserver'
    
    cd $matchdir
    $serverbin include="$include" server::team_l_start="${teamAComm}" server::team_r_start="${teamBComm}" CSVSaver::save='true' CSVSaver::filename='out.csv'
    
    

    Then if you sometimes want to ignore the debug output, redirect stderr somewhere.

提交回复
热议问题