Reputation: 1
I am having a real pickle of a time and curious if it is possible.... Trying to write a single script to be used on a thumb drive or ran from another computer via terminal.
**Goal: Single script to check if host system is Windows or Cisco IOS. If Windows is the script host, i want the script to check for the TFTP Server and if it is running, if not installed it will call the package then start the tftp server and create config-archive and a status folder.
If Cisco Router IOS is the Script Host, i want to ping a dedicated TFTP Server or ask for server IP, then to check for the required folders as above. I do not want the script to request the script from another source. The script will be configured for initially a home lab setup then production after testing.**
Problem is I am trying to find the correct statement of script to check both and pass the results to direct the path of the script to the windows section or the Cisco IOS section of the script. or is this even possible?
Reading and Reading, forum after forum, looking at multiple scripts.
so far.... from python terminal
import platform
platform.system()
returns 'win32'
in Visual Studio Code (Python)
import platform
SYS_OS=platform.system()
print("Current OS: ", SYS_OS)
Result>
Could not find platform independent libraries <prefix>
Could not find platform independent libraries <prefix>
Current OS: Windows
if i try to SYS.PLATFORM I get errors though sys has been imported??? "platform" is light blue instead of orange in Visual Studio...
import sys
SYS_OS_WIN=sys.platform()
print("Current OS: ", SYS_OS_WIN)
SYS_OS_WIN=sys.platform()
^^^^^^^^^^^^^^
TypeError: 'str' object is not callable
alot of what i have looked at calls sys.platform() rather than platform.system()
and i haven't figured out how to even perform the Cisco IOS Check yet, been stuck with the Windows Sys. versus the Platform. modules and how to effectively tie the cisco check into the if then or else do statements...
Update 5-31-2023 09:00: Reply to comment ewokx:
ok, so i wasn't thinking about that being a string even though it was telling me lol. so if i run it this way:
import sys
SYS_OS_WIN=sys.platform
print("Current OS: ", SYS_OS_WIN)
it returns the output:
Could not find platform independent libraries <prefix>
Could not find platform independent libraries <prefix>
Current OS: win32
So, my main question how to check both for windows and cisco ios in the same script and store the result?
I think i will be using "Platform.System()" to get the overall results i want. also seems to be more compatible with cross platform. Unless there is a better way to work with both systems.
Upvotes: 0
Views: 145
Reputation: 43097
i haven't figured out how to even perform the Cisco IOS Check yet, been stuck with the Windows Sys. versus the Platform. modules and how to effectively tie the cisco check
To detect a binary choice of Windows or Cisco IOS, use:
import sys
PLATFORM = 'ciscoios'
if sys.platform=='win32':
PLATFORM = sys.platform
else:
# Insert Cisco IOS python imports here
pass
Upvotes: 0