- cmd = f"sh -c \"cd {Constants.TREX_INSTALL_DIR}/scripts/ && " \
- f"nohup ./t-rex-64 -i -c {Constants.TREX_CORE_COUNT} --hdrh " \
- f"{u' --astf' if osi_layer == u'L7' else u''} " \
- f"--prefix $(hostname) {Constants.TREX_EXTRA_CMDLINE} " \
- f"> /tmp/trex.log 2>&1 &\" > /dev/null"
+ cd_cmd = f"cd '{Constants.TREX_INSTALL_DIR}/scripts/'"
+ trex_cmd = OptionString([u"nohup", u"./t-rex-64"])
+ trex_cmd.add(u"-i")
+ trex_cmd.add(u"--prefix $(hostname)")
+ trex_cmd.add(u"--hdrh")
+ trex_cmd.add(u"--no-scapy-server")
+ trex_cmd.add_if(u"--astf", osi_layer == u"L7")
+ # OptionString does not create double space if extra is empty.
+ trex_cmd.add(f"{Constants.TREX_EXTRA_CMDLINE}")
+ inner_command = f"{cd_cmd} && {trex_cmd} > /tmp/trex.log 2>&1 &"
+ cmd = f"sh -c \"{inner_command}\" > /dev/null"