On 15/09/17 21:50, Derek Smith wrote: > if nput1 == "file" : > nput2 = input("Please provide your input file? ") > nput2 = nput2.lower()
Are you sure the filenames will always be lower case? > print (nput2) > fh = open(nput2,"r") You should wrap that in a try/except in case there is an issue opening the file, like it doesn't exist or you don't have permission. > > for ln in fh: > ln = ln.rstrip() > os.system("/usr/bin/dsmadmc -id=dereksmith -password=x -dataonly=yes > move drm %s" %ln, "tost=onsiter") > os.system("/usr/bin/dsmadmc -id=dereksmith -password=x -dataonly=yes > move drm %s" %ln, "wherest=vaultr tost=onsiter") > Strictly speaking you should close() the file here since you opened it. > elif nput1 == "cli" : > vols = [] > vols = input("Please enter your volume ids, comma delimited? ") > vols = vols.upper() > for vols in vols : Here you assign an empty list to vols Then you assign a string to vols, losing the array then you convert the string to upper case - are volume IDs always upper case? Then you go into a really confusing for loop where you assign the characters of vols to vols which seems to work OK except that at the end of the loop vols will equal the last character in vols... It would be much easier to read and understand if you used a different name for the loop variable. > vols = vols.rstrip() > print("/usr/bin/dsmadmc -id=dereksmith -password=dereksmith > -dataonly=yes move drm %s" %vols, "tost=onsiter") > Is your input 'file' based or 'cli' based? cli > Please enter your volume ids, comma delimited? r20344l5,r20355l5 > /usr/bin/dsmadmc -id=dereksmith -password=x -dataonly=yes move drm R > tost=onsiter > /usr/bin/dsmadmc -id=dereksmith -password=x -dataonly=yes move drm 2 > tost=onsiter > /usr/bin/dsmadmc -id=dereksmith -password=x -dataonly=yes move drm 0 > tost=onsiter > /usr/bin/dsmadmc -id=dereksmith -password=x -dataonly=yes move drm 3 > tost=onsiter > /usr/bin/dsmadmc -id=dereksmith -password=x -dataonly=yes move drm 4 > tost=onsite > Its printing each element per line. Because you never split the line into its separate elements, Python just sees a long string. You need to add a vols = vols.split(',') to get a list of substrings. You probably want that just after the call to upper() Incidentally if you are using string formatting its more common to just have a single string and the insereted value at the ehnd, so your line would look like: print("/usr/bin/dsmadmc -id=dereksmith -password=dereksmith -dataonly=yes move drm %s tost=onsiter" % vols) And of course the name/passwd should really be parameterized: print("/usr/bin/dsmadmc -id=%s -password=%s -dataonly=yes move drm %s tost=onsiter" % (nm, pwd, vols) ) -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor