I am trying to run perl script called mib2c for UCD-SNMP on Linux. To automate the process , I want to have a java program that does the following:
1. Sets an environment variable i.e export MIBS=ALL
2. Runs the perl script with the above settings i.e /root/snmp/ucd-snmp-4.1.2/local/mib2c <options>.
I thought that I could do the above using Runtime class like :
Runtime myRuntime = Runtime.getRuntime();
Process myProcess = myRuntime.exec("export MIBS=ALL");
and then use the output stream of the "myProcess" to pass the command for running the perl script.
However , I realised that this is not possible as I get the following message when I read the error streams of the process:
export: local server: Call timed out
export: MIBS=ALL: No such file or directory
Another approach could be to to open a socket on port 23(i.e telnet session) and then give login and password and then pass the commands. However , I want this to be my last resort as this would require password etc. which would decrease the security + the code would be bulky.
Can anyone provide a solution for my problem?