我的perl脚本遇到了一个非常奇怪的问题.我真的不知道,那里发生了什么,也许你会看到它......
我的脚本用于Net::SSH::Perl通过SSH连接到主机.之后我head -20在config.ini上搜索一些模式(版本号).
在我打印版本号后,cat其他文件大约有700行.
现在发生的是,脚本不是打印版本号,而是打印整个700行文件.除非我print "\n"x10; 直接添加版本打印.
这种行为对我没有任何意义,但我相信你们中的一个会比我更聪明并且知道答案:)
脚本下方:
1 #!/usr/local/bin/perl -w
2 use lib './';
3 use strict;
4
5 use GetVersions;
6 use Net::SSH::Perl;
7
8
9 my $ssh = Net::SSH::Perl->new(
10 'host',
11 identity_files => ['~/.ssh/id_rsa']
12 );
13
14 $ssh->login('user');
15
16 my $ver_regex = '^psadm\.version\s*=\s*rel_(.+)$';
17
18 my ($file, $err, $exit) = $ssh->cmd('head -20 /config.ini');
19 my $version = $file =~ /$ver_regex/m;
20 print …Run Code Online (Sandbox Code Playgroud) 我是新来的期待脚本的人,并且有一个用例,其中需要从已经使用Expect脚本执行过ssh的计算机上执行ssh。这是我的代码片段
#!/usr/bin/expect -f
set timeout 60
spawn ssh username@machine1.domain.com
expect "Password: "
send "Password\r"
send "\r" # This is successful. I am able to login successfully to the first machine
set timeout 60
spawn ssh username@machine2.domain.com #This fails
Run Code Online (Sandbox Code Playgroud)
这需要花费一些时间,并且无法说出ssh:连接到host machine2.domain.com端口22:操作超时。我知道22是ssh运行的默认端口,我可以通过给ssh提供-p选项来手动覆盖它。
如果我尝试在没有期望脚本的情况下独立进行ssh操作,则会出现提示要求我输入的提示(是/否)。如果我不使用期望脚本直接执行ssh,将从何处获取正确的端口。如果我不需要在Shell上输入端口号,那么如果我使用的是期望脚本,为什么还要输入端口号。
我尝试使用ssh运行远程awk语句.我的代码是:
ssh username@hostIP "awk 'NR==1 {max=0;min=1} NR>1 {if (max<\$3) max=\$3}END {print max}' FS=\",\" /path_to_my_file"
Run Code Online (Sandbox Code Playgroud)
当我运行此命令时,我没有收到任何错误消息,但命令不起作用,并且不生成输出但只是挂起所以我需要通过ctrl + c取消它.
有什么我想念的吗?
我想basename从循环中获取,但这只会让我回归"*".
FILES=("/home/aaaa/bbbb/*") #Get all folders
for f in "${FILES[@]}"
do
basename "$f"
done
Run Code Online (Sandbox Code Playgroud)
我做错了什么?
这是我第一次使用linode并将Rails应用程序上传到VPS,所以我可能会跳过一些明显的东西.
我按照两个教程 Ryan Bates视频部署到vps 和 David在Stackoverflow上的答案
我想要在Linode上部署我的rails应用程序(Ubuntu 13.10)
当我执行命令 bundle exec cap deploy:update
由于公钥,我得到了Linode无法连接到github的错误
user:my-app User$ bundle exec cap deploy:update
* 2014-02-12 17:19:46 executing `deploy:update'
** transaction: start
* 2014-02-12 17:19:46 executing `deploy:update_code'
updating the cached checkout on all servers
executing locally: "git ls-remote git@github.com:user/my-app.git master"
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
*** [deploy:update_code] rolling back
* executing "rm -rf /home/user/apps/my-app/releases/20140212091953; true"
servers: ["XXX.XXX.XX.XX"]
[XXX.XXX.XX.XX] executing command
command finished in 4607ms
Command git ls-remote git@github.com:user/my-app.git master …Run Code Online (Sandbox Code Playgroud) 我正在尝试远程运行shell脚本.我在一台机器上有一个资源(.txt文件),在另一台机器上有一个shell脚本,但是在同一个网络中.该脚本驻留在特定目录中,并且该脚本获取一些二进制文件,这些文件驻留在目标计算机中的所有其他目录中.现在,我无法远程运行脚本.但我可以运行一个没有任何本地依赖项的简单shell程序.你能建议一个解决方案来解决这个问题吗?
这是我用来运行shell-script-without-any-dependencies的命令.
cat input.txt | ssh clrg@192.168.2.22 "sh path/to/shell/script/tokenize.sh"
Run Code Online (Sandbox Code Playgroud)
在运行具有依赖项的脚本时,我收到以下错误,
"ambiguous redirect"
../../deter-4/bin/determine: No such file or directory
../../deter-4/bin/determine1: No such file or directory
Run Code Online (Sandbox Code Playgroud)
现在,如何在运行shell脚本时告诉接受依赖项
我正试图通过jenkins工作中的capistrano 3部署到服务器.
"cap environment deploy"完全可以从我的mac中获得我的信誉,但在jenkins下,使用部署信誉,我遇到了一个问题.
最奇怪的是前几个git命令成功,但是当capistrano进入"git remote update"时,服务器挂起时出现"未授权"错误.我通过ssh'ing到服务器并从/ var/www/repo运行'git remote update'来验证这一点.
我有密钥转发设置 - 下面是我的詹金斯工作:
eval $(ssh-agent)
ssh-add ~/.ssh/keyname.pem
cap staging deploy
Run Code Online (Sandbox Code Playgroud)
我不知道capistrano中发生了什么会导致第一个git命令成功('git ls-remote'),但"git remote update"失败.是的,密钥已在github上作为部署密钥添加到repo中,并且在deploy.rb和〜/ .ssh/config中启用了密钥转发.
下面是来自'cap staging deploy'的失败日志示例,在Jenkins框上以Jenkins用户身份运行:
INFO [d3e19149] Running /usr/bin/env mkdir -p /tmp/project/ on server.xxxxxyyyy.com
DEBUG [d3e19149] Command: /usr/bin/env mkdir -p /tmp/project/
INFO [d3e19149] Finished in 0.943 seconds with exit status 0 (successful).
DEBUG Uploading /tmp/project/git-ssh.sh 0.0%
INFO Uploading /tmp/project/git-ssh.sh 100.0%
INFO [43533553] Running /usr/bin/env chmod +x /tmp/project/git-ssh.sh on server.xxxxxyyyy.com
DEBUG [43533553] Command: /usr/bin/env chmod +x /tmp/project/git-ssh.sh …Run Code Online (Sandbox Code Playgroud) 我正在关注生成SSH密钥的GitHub指南.我在第3步,第5步
将您的密钥粘贴到"密钥"字段中.
我怎么可以找到钥匙?我在哪里打开然后将其粘贴到GitHub上?
我试过这个
$ open ~/.ssh/id_rsa.pub
Couldn't get a file descriptor referring to the console
$ ssh-rsa
ssh-rsa: command not found
Run Code Online (Sandbox Code Playgroud)
我该如何打开.ssh文件?
我在laravel项目文件夹中运行以下命令,并得到以下错误。
rakib$ envoy run list --env=production
[ubuntu@54.187.123.4]: Permission denied (publickey).
Run Code Online (Sandbox Code Playgroud)
但是我可以使用以下命令成功ssh:
ssh -i ~/.ssh/sw-new.pem ubuntu@54.187.123.4
Run Code Online (Sandbox Code Playgroud)
我的〜/ .ssh / config文件内容如下所示:
Host 54.187.123.4
IdentityFile ~/.ssh/sw-new.pem
Run Code Online (Sandbox Code Playgroud)
谁能建议我出现“权限被拒绝”错误的可能原因是什么?
我有一个包含一系列IP的数组.现在我正在尝试通过ssh连接到这些IP并回显它们的主机名.我遇到了这个Stackoverflow的答案,但没有得到太多的信息.这就是我所拥有的:
#!/usr/bin/perl
use warnings;
use strict;
use Term::ANSIColor;
print colored( "Number of machines: \n", 'green' );
my $number = <>;
my @arr = ();
my $ip = 0;
while (@arr < $number) {
print colored( "\nIP Address: \n", 'green' );
my $IP = <STDIN>;
chomp $IP;
push @arr, $IP;
}
print colored( "this is the hostname:\n", 'green' ); foreach $ip (@arr) {
print "`ssh host\@$ip hostname \n`";
}
Run Code Online (Sandbox Code Playgroud)
但我得到以下错误:
Can't use string ("IP") as an ARRAY ref while …Run Code Online (Sandbox Code Playgroud)