1

From the command line I can run a python script with some arguments and all is well.

The problem I have is I'm trying to run this script (an a couple of others) many times using a bash scrip which reads the arguments each time from a CSV file. The arguments include "account" which is a domain name, "password1" & "password2" which are passwords that may include special characters.

This is my script to far:

#!/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

My problem is when I run this script, the output from the various python scripts (those using the password variables) suggests that their is a problem logging in, i.e. the password variables are not correct.

It's almost as if the arguments aren't being supplied correctly each time.

Can anyone shed some light?

2
  • Quote variables: "$account" Commented Jun 15, 2013 at 15:50
  • you are using abelpass and entapass in read, yet $password1 and $password2 in the body of the while loop. Are those typo, or are they actually in your script? Commented Jun 15, 2013 at 15:51

1 Answer 1

2
while read -r account abelpass entapass

You are reading abelpass & entapass but passing password1 and password2 ! Didn't you meant to use

while read -r account password1 password2

?

Sign up to request clarification or add additional context in comments.

5 Comments

You can also prefix the read command with the correct value of IFS, avoiding the need to save the old value. while IFS=, read -r account password1 password2.
Sorry yes, I changed the names for posting on here but forgot those two. This isn't the problem... I've updated the post accordingly. Thanks
@DaveLough Quote your variables "$account" "$password1: "$password2" for all calls. Did you check that arguments are received correctly in python script by printing them?
@KingsIndian how do i do that?
print 'Number of arguments:', len(sys.argv) print 'Arguments:', str(sys.argv) Add these lines in your python scripts to see if the arguments are passed as you expected. You need to import sys if you haven't done already.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.