I have this code:
print("Welcome to the NetBackup Symbolic Link Generator.\n")
print("Log into a server and run the command 'ls $ORACLE_BASE/admin'. Copy the list of folders (database names), but omit filenames and/or +ASM, then paste below.\n")
databases=input("Enter databases: ")
numNodes=input("Enter the number of nodes (1, 2, or 3): ")
print("\nCopy the output below and paste into the SSH session as \"orainst\".\n")
if int(numNodes) == 1:
streams="1a 1b 1c"
elif int(numNodes) == 2:
streams="1a 2a 1b 2b 1c 2c"
else:
streams="1a 2a 3a 1b 2b 3b 1c 2c 3c"
db_list = databases.split()
streams_list= streams.split()
for db in db_list:
print(db)
input("Press \"Enter\" to exit.")
Everything generally works, unless the user pastes something that contains a newline like:
dbone dbtwo tbtree
dbfour dbfive
And then I end up with this:
Welcome to the NetBackup Symbolic Link Generator.
Log into a server and run the command 'ls $ORACLE_BASE/admin'. Copy the list of folders (database names), but omit filenames and/or +ASM, then paste below.
Enter databases: dbone dbtwo tbtree
dbfour dbfive
Enter the number of nodes (1, 2, or 3):
Copy the output below and paste into the SSH session as "orainst".
Traceback (most recent call last):
File "C:\Users\en195d\Documents\Personal\Project\Python\NetBackupSymLinkGen.py", line 12, in <module>
if int(numNodes) == 1:
ValueError: invalid literal for int() with base 10: 'dbfour dbfive'
>>>
How can I handle input that contains newlines?