在远程计算机中执行Jar文件时出错 [英] Error in executing a Jar file in remote machine

查看:82
本文介绍了在远程计算机中执行Jar文件时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试执行远程计算机中存在的jar file.当我从本地计算机执行以下命令时,出现错误:

I am trying to executing a jar file which is present in remote machine. When I execute below command from my local machine I get error:

ssh -i /root/.ssh/pem_file user@[host_ip]:/home/user/folder1/java -cp jar1.jar -a option1 -e user1@gmail.com -f TextFile.txt

/home/user/folder1/是远程计算机上jar file所在的位置.我得到的错误是:

/home/user/folder1/ is the location where jar file is present on remote machine.The error I get is:

Unknown cipher type 'p'

然后我查找了此错误,并发现了ssh我们可能不需要它.因此,我从中删除了-cp并执行了以下命令:

I then looked up for this error and found out the with ssh we may not need it. So, I removed -cp from it and executed this command:

ssh -i /root/.ssh/pem_file user@[host_ip]:/home/user/folder1/java jar1.jar -a option1 -e user1@gmail.com -f TextFile.txt

现在我收到错误提示:

ssh: Could not resolve hostname [host name]:/home/user/folder1/java: nodename nor servname provided, or not known

如何解决此错误?

推荐答案

该命令应在主机名之间用空格而不是冒号分隔后传递给ssh,例如:

The command should be passed to ssh after hostname separated by space not colon, like this:

ssh -i /root/.ssh/pem_file user@[host_ip] /home/user/folder1/java -cp jar1.jar -a option1 -e user1@gmail.com -f TextFile.txt

如果命令中的某些部分在发送到远程主机之前可以被本地外壳解析(例如cd /tmp && lscat /file | uniq > some.log),则应将其用单引号引起来:

If you have parts in the command that could be parsed by your local shell before sent to remote host (for example cd /tmp && ls or cat /file | uniq > some.log) it should be enclosed in single quotes:

ssh -i /root/.ssh/pem_file user@[host_ip] 'cd /home/user/folder1 && java -jar jar1.jar -a option1 -e user1@gmail.com -f TextFile.txt'

这篇关于在远程计算机中执行Jar文件时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆