Do I write the cubegen command line after the coordinates of the optimized structure? If yes, is there something like "EOF" to be written in the line before the cubegen command line? Should I also write "Exit" after the cubegen command line?
If you have a large fchk file, generate the cube file on command line instead of submitting it as a job. If you need more memory, there is a special %mem for Gaussian that can be accessed from command line (GAUSS_MEMDEF environment variable).
Use export GAUSS_MEMDEF=100MW to allocate memory.
Then generate cubes files using: cubegen 1 Fdensity file.fchk file.cube -5 < file.pnt or cubegen nproc density file.fchk file.cube 80 for ESP.
If you have to submit your job using a scheduler program, you can write a script appropriate to the scheduler which is used on your system, make the necessary adjustment (for example module load something, set the PATH and LD_LIBRARY_PATH, and so on ), then write the "cubegen ..." command at the end of the script. Finally, submit the script with a suitable command (for SGE: qsub YOUR_SCRIPT_NAME.job).