产卵命令未找到

编程入门 行业动态 更新时间:2024-10-27 03:36:38
本文介绍了产卵命令未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个错误尝试运行sh文件

I have an error trying to run a .sh file

line 2: spawn: command not found ": no such file or directory bash.sh: line 3: expect: command not found bash.sh: line 4: send: command not found

#!/usr/bin/expect -f spawn sftp -o IdentityFile=MyFile.ppk 500200243@XXX.XXX.XXX.XXX expect "XXX.XXX.XXX.XXX.gatewayEnter passphrase for key 'MyFile.ppk.ppk':" send "myPassword"

任何想法,为什么会发生?

Any idea why it happens?

推荐答案

它的工作原理OK,我(从错误SFTP: SSH:无法解析主机名XXX.XXX.XXX.XXX:姓名或服务不知道),尽​​管 .SH 扩展的的预计(的 TCL )脚本是有点倒胃口; - )

It works OK for me (error from sftp: ssh: Could not resolve hostname XXX.XXX.XXX.XXX: Name or service not known), though the .sh extension for an expect (tcl) script is a little off-putting ;-)

通常,当这种莫名/ UN predictable行为发生,这是因为剧本是根据的窗口(记事本),它使用 \\ r \\ n 划线。这起严重破坏 UNIX /的的Linux 脚本,因为只有 \\ n 有望作为行分隔符。

Often when this sort of unexplainable/unpredictable behavior happens, it is because the script was edited under windows (notepad.exe), which uses \r\n to delimit lines. This plays havoc with unix/linux scripts, as only \n is expected as a line delimiter.

您可以使用的 DOS2UNIX的和 unix2dos 公用事业以这两种格式之间进行转换。作为一个实验,我转换你的脚本为DOS格式,果然得到了类似的错误:

You can use the dos2unix and unix2dos utilities to convert between the two formats. As an experiment, I converted your script to "dos" format, and sure enough got a similar error:

ubuntu@ubuntu:~$ unix2dos bash.sh unix2dos: converting file bash.sh to DOS format ... ubuntu@ubuntu:~$ ./bash.sh ": no such file or directory ubuntu@ubuntu:~$ dos2unix bash.sh dos2unix: converting file bash.sh to Unix format ... ubuntu@ubuntu:~$ ./bash.sh spawn sftp -o IdentityFile=MyFile.ppk 500200243@XXX.XXX.XXX.XXX ssh: Could not resolve hostname XXX.XXX.XXX.XXX: Name or service not known Couldn't read packet: Connection reset by peer send: spawn id exp6 not open while executing "send "myPassword"" (file "./bash.sh" line 4) ubuntu@ubuntu:~$

更多推荐

产卵命令未找到

本文发布于:2023-07-05 01:13:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1031229.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:未找到   命令

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!