Q:

How to redirect qsub output into a text file

In my code I want to use the qsub output information such as job ID, node name etc., so I'm think about redirecting the qsub output into some file at the time when the node is allocated, which then can be later used by my code.
For example, when I request a interactive node using 
[abc@mike1 ~]$ qsub -V -I -l walltime=01:00:00,nodes=1:ppn=16

I'm getting these output
qsub: waiting for job 48536.mike3 to start
qsub: job 48536.mike3 ready

--------------------------------------
Running PBS prologue script
--------------------------------------
User and Job Data:
--------------------------------------
Job ID:    48536.mike3
Username:  abc
Group:     Users
Date:      01-Sep-2013 19:14
Node:      mike099 (4657)
--------------------------------------
PBS has allocated the following nodes:

mike099

A total of 16 processors on 1 nodes allocated
---------------------------------------------
Check nodes and clean them of stray processes
---------------------------------------------
Checking node mike099 19:14:52 
Done clearing all the allocated nodes
------------------------------------------------------
Concluding PBS prologue script - 01-Sep-2013 19:14:52
------------------------------------------------------
[abc@mike099 ~]$

Can I redirect these information into a text file, at the time the node is allocated?
I tried something like
[abc@mike1 ~]$ qsub -V -I -l walltime=01:00:00,nodes=1:ppn=16 >> 1.txt

and it gave me an error
qsub:   standard input and output must be a terminal for 
    interactive job submission

A:

I asked our system manager, and he told me that the PBS environmental variables can be used to get these information:
PBS_NODEFILE : File containing list of allocated nodes
PBS_O_WORKDIR: Directory from where job is submitted
PBS_O_QUEUE: Queue job was submitted to
PBS_JOBID: Job ID number
PBS_JOBNAME: The name of the job.
PBS_NP: Number of processes requested
PBS_NUM_PPN: Number of processors per node requested
etc

For example, if I want to get the name of the nodes, I can use 
sort $PBS_NODEFILE | uniq

it will return
mike409
mike410
mike411
mike412

