1

I have a script that connect to a Network device. It runs some commands and basically I want to output the SSH commands that are being executed.

To make myself clearer, I connect to one device, execute the commands "execute fmscript showlog " and it shows some output. The thing is in the log file where the output is redirected, I can't see the "execute fmscript etc." command printed into the file, just the results.

sshpass -p 12345678 ssh admi[email protected] 'execute fmscript showlog FG300D-1' > output.txt 

And this is the result:

FMG-VM64-KVM # 

Starting log (Run on device)

FG300D-1 $  fnsysctl ps -A
PID       UID     GID     STATE   CMD

On the first line you can see FMG-VM64# What I want to see is "FMG-VM64#execute fmscript showlog FG300D-1".

Any way of doing this? I tried with tee with no success.

1 Answer 1

1

How about

CMD='execute fmscript showlog FG300D-1'
echo $CMD > output.txt
sshpass -p 12345678 ssh [email protected] "$CMD" >> output.txt

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .