is this a type 1 or type 2 nsh job ?
Execute the script separately against each host (using runscript)
So the problem w/ using the type 1 (run script) is that the appserver will first 'cd' to the target, then run the commands in the script. this is not good for 'agentinfo' because if the agent is offline, has a mapping or some other issue, the agentinfo command will never run. i'm also not sure what the USER is doing in there and $USER is usually a reserved variable that echos out the shell user the process/session is running as on unix, so you might want to use a different variable for that.
i think what you should do is this.
create a script that runs:
'agentinfo -f $1'
then create the script object as a 'type 2' - execute the script once. add a parameter to the script, call it 'targets' and the value should be %f
then create a job from that and run it. you could change this a bit and use the '-c' option to get csv formatted output