SSH在bash脚本搞乱文件中读取 [英] SSH in Bash Script Messing Up File Read

查看:176
本文介绍了SSH在bash脚本搞乱文件中读取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本,由线读取文件中的行和做的东西基于它的读取。其中一个它做的事情是SSH到远程服务器,并得到一些信息。出于某种原因,这完全超出了我,这将停止从文件行的读取。

I have a script that reads a file line by line and does stuff based on what it reads. One of the things it does is ssh to a remote server and gets some information. For some reason that's completely beyond me, this stops the reading of lines from the file.

脚本实质上是(我剪了很多它简化问题,所以喜欢它并没有真正做任何事情,不用担心,如果它看起来):

The script is essentially (I've cut out a lot of it to simplify the question, so don't worry if it looks like it doesn't really do anything):

cat $csv | while read line; do
   shopt -s nocasematch
   for j in "${file_list[@]}"; do
      found=0;
      for i in $(ssh some_server "ls /some_path/${line:0:1}/${line:1:1}/$line*"); do
         if [[ $i =~ .*$j$ ]]; then
            echo "do something";
            found=1;
            break;
         fi;
      done;
      if [[ $found -ne 1 ]]; then
         echo "don't have $j";
      fi;
      if [[ $found -ne 1 && $j == '\.pdf' ]]; then
         getPDF $line ${dest};
      fi;
   done;
   shopt -u nocasematch
done

本脚本卷起仅在CSV的第一线运行。如果我用别的替代脚本的SSH的一部分,虽然,它通过运行在该文件的所有行的所有道路。是什么赋予了?

This script winds up only running on the first line of the csv. If I replace the "ssh" part of the script with anything else though, it runs all the way through on all lines of the file. What gives?

推荐答案

SSH 消耗标准输入。通 -n

这篇关于SSH在bash脚本搞乱文件中读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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