Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re as _re
- import os as _os
- import java.lang.System as System # pyright: ignore[reportMissingImports]
- def get_filename():
- command = str(System.getProperties().get("sun.java.command"))
- # current_dir = System.getProperty("user.dir")
- if command.find("com.ibm.ws.admin.services.WsAdmin") != -1:
- filename_regex = r'-f\s+(.*\.py)' # wsadmin.sh -f 'filename.py'
- elif command.find("com.vtservices.opat.batch.impl.websphere.RunWasBatch") != -1:
- filename_regex = r'-executeScript\s+(.*\.py)' # myWasBatch.sh -executeScript 'filename.py'
- else:
- raise Exception("Unsupported CLI command: '%s'" % command)
- filename = _re.search(filename_regex, command)
- if filename is None:
- return None
- return _os.path.abspath(filename.group(1))
- if __name__ == '__main__':
- print("Current script is '%s'" % str(get_filename()))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement