MCPcopy Create free account
hub / github.com/saltstack/salt / execute_script

Method execute_script

salt/client/ssh/__init__.py:1994–2017  ·  view source on GitHub ↗

execute a script on the minion then delete

(self, script, extension="py", pre_dir="", script_args=None)

Source from the content-addressed store, hash-verified

1992 return cmd
1993
1994 def execute_script(self, script, extension="py", pre_dir="", script_args=None):
1995 """
1996 execute a script on the minion then delete
1997 """
1998 args = ""
1999 if script_args:
2000 if not isinstance(script_args, (list, tuple)):
2001 script_args = shlex.split(str(script_args))
2002 args = " {}".format(" ".join([shlex.quote(str(el)) for el in script_args]))
2003 if extension == "ps1":
2004 ret = self.shell.exec_cmd(f'"powershell {script}"')
2005 else:
2006 if not self.winrm:
2007 ret = self.shell.exec_cmd(f"/bin/sh '{pre_dir}{script}'{args}")
2008 else:
2009 ret = saltwinshell.call_python(self, script)
2010
2011 # Remove file from target system
2012 if not self.winrm:
2013 self.shell.exec_cmd(f"rm '{pre_dir}{script}'")
2014 else:
2015 self.shell.exec_cmd(f"del {script}")
2016
2017 return ret
2018
2019 def shim_cmd(self, cmd_str, extension="py"):
2020 """

Callers 3

run_ssh_pre_flightMethod · 0.95
shim_cmdMethod · 0.95
test_execute_scriptFunction · 0.95

Calls 2

formatMethod · 0.80
exec_cmdMethod · 0.80

Tested by 1

test_execute_scriptFunction · 0.76