I have a problem i want to send code pscp like that in java program i wanna send this code root@1xx.2xx.3X.1x:/usr/local/se/log c:/
Asked
Active
Viewed 650 times
1 Answers
1
You can run native scripts inside a Java program using the Runtime class:
class Test {
public static void main(String[] args) {
Runtime.getRuntime().exec("pscp.exe C:\xm root@1xx.2xx.3X.1x:/usr/local/se/log ");
}
}

Vito Royeca
- 657
- 10
- 20
-
Updated the code. Also check the correct syntax of the pscp command: pscp.exe /help – Vito Royeca Aug 26 '15 at 15:11
-
okey i wanna run pscp in cmd screen i wanna send this code in command.exe how to ? pscp C:\xm root@172.168.14.25:/usr/local/se/log/*.* – ramcolinho Aug 26 '15 at 15:26
-
See my updated code. Have you tried compiling and running it? I already told you that the Runtime class can execute cmd.exe commands. If you think it is the correct solution mark it as the appropriate answer. – Vito Royeca Aug 26 '15 at 16:19
-
Firstly i open pscp.exe like this C:/pscp.exe after we can need this code root@192.168.0.1:/usr/local/se/log/*.* but i cant.. ! :/ – ramcolinho Aug 27 '15 at 11:17
-
i solved @jovit.royeca thank you for help :)) class Test { public static void main(String[] args) { Runtime.getRuntime().exec("pscp.exe C:\xm root@1xx.2xx.3X.1x:/usr/local/se/log "); } } – ramcolinho Aug 27 '15 at 14:18
-
I'm glad my code helped you. Mark it as the appropriate answer then. – Vito Royeca Aug 27 '15 at 14:52