Showing posts with label OutputStream. Show all posts
Showing posts with label OutputStream. Show all posts

Execute series of commands in java (In same command prompt) id not possible another window



I need to execute these commands in java.TRried PrintStream ,OutputStream , process unbale to get desired output. When i write in Process class I get an error: java.io.IOException: Cannot run program "cd C:\Users\c200433\Desktop\Ana": CreateProcess error=2, The system cannot find the file specified .



String[] cmd = new String[] { "cd C:\\Users\\c200433\\Desktop\\Ana" };
Process p = Runtime.getRuntime().exec(cmd);



OutputStream

tabcmd logout
tabcmd login -s http://localhost:80 -u c233 -p veh1@#
I have written code as

PrintStream ps = new PrintStream(child.getOutputStream());
OutputStream out = child.getOutputStream();
out.write("tabcmd logout"getBytes());
out.write("cd C:\\Program Files\\Tableau\\Tableau Server\\8.2\\bin".getBytes());

ABove commands were not working so i have used (by getbytes)

PrintStream ps = new PrintStream(child.getOutputStream());
ps.append("tabcmd logout"getBytes());
ps.aapend("cd C:\\Program Files\\Tableau\\Tableau Server\\8.2\\bin".getBytes());

Commands are not being executed.Can some one guide me.My Process flow is as follows.
First 3 commands

cd C:\Program Files\Tableau\Tableau Server\8.2\bin
tabcmd logout
tabcmd login -s http://localhost:80 -u c200433 -p venkatesh1@#


Then my custom java files where it replaces xml files and later upload it to server using this command

ps.append("tabcmd publish C:\\Users\\c200433\\Desktop\\Ana\\")
.append(filename)
.append(" --db-username IIP_R --db-password Ytpq9dw");

Read more ...