linux - 如何在从 csv 文件获取参数的 bash 脚本中运行命令

标签 linux bash csv

我可以从命令行运行带有一些参数的 python 脚本,一切正常。

我遇到的问题是我试图使用 bash 脚本多次运行此脚本(以及其他几个脚本),该脚本每次都从 CSV 文件中读取参数。参数包括“account”(域名)、“password1”和“password2”(可能包含特殊字符的密码)。

到目前为止,这是我的脚本:

#!/bin/bash

INPUT=accountlist.csv
OLDIFS=$IFS
IFS=,
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read -r account $password1 $password2
do

/tmp/migration_imapcopy $account $password1 $password2  
/tmp/migration_markmigrated $account
/tmp/migration_dnscheck abel $account
/tmp/migration_imapcopy $account $password1 $password2

done < $INPUT
IFS=$OLDIFS

我的问题是当我运行这个脚本时,各种 python 脚本(使用密码变量的脚本)的输出表明它们是登录问题,即密码变量不正确。

好像每次都没有正确提供参数。

任何人都可以解释一下吗?

最佳答案

while read -r account abelpass entapass

您正在阅读 abelpassentapass 但传递了 password1password2 !你不是打算用

while read -r account password1 password2

?

关于linux - 如何在从 csv 文件获取参数的 bash 脚本中运行命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17125328/

相关文章:

linux - 一次读取一个输入文件作为输入传递给 grep

linux - x64 NASM 汇编程序在程序开始时显示段错误

linux - Vim:如何打开名称由运行 shell 命令确定的文件

bash - 遍历跳过第一个参数

bash - 用于导入的 sqlite 字段分隔符

python - 当数组数据类型和格式说明符不匹配时,如何将数组堆栈保存到 .csv?

linux - 如何从 bash shell 获取输出

php - mysql服务器重启如何影响当前正在运行的作业

python - 为什么 pandas.to_datetime 对于 '2014/12/31' 等非标准时间格式很慢

linux - 文件转换和从 Linux 中的文件中删除特殊字符