Your code reveals that you have not included any time delay between sending the command and recieving !!!
I suspect that you are missing a character or two from the command line!!!
If your download an instrument driver From NI instrument driver site
https://sine.ni.com/apps/utf8/niid_web_display.download_page?p_id_guid=E3B19B3E90E6659CE034080020E74861
and check out the examples that shoul set you on the right track.
On most Agilent network analyser you have the option of echoing hte front panel key commands !!
Thus set the menu so that the screen illustrates what actual GPIB command need to be recieved by the processor to
execute the instruction. This way you can see precisely what command word should be used to achieve
your goal. (It is necessary to repeat commands several time to actual see what is written !!!)
Go for it
The user manual should help to set up the echo command to see the commands.
chow xseadog