Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent to Unix eval in Windows

Was wondering how you'd do the following in Windows:

From a c shell script (extension csh), I'm running a Python script within an 'eval' method so that the output from the script affects the shell environment. Looks like this:

eval `python -c "import sys; run_my_code_here(); "`

Was wondering how I would do something like the eval statement in Windows using Windows' built in CMD shell. I want to run a Python script within a Windows script and have the script run what the Python script prints out.

** update: specified interest in running from CMD shell.

like image 865
johannix Avatar asked Jul 28 '09 17:07

johannix


People also ask

What is Windows eval command?

The Eval function returns a Variant that is either a string or a numeric type. The argument stringexpr must be an expression that is stored in a string.

What is Unix eval?

eval is a built-in Linux command which is used to execute arguments as a shell command. It combines arguments into a single string and uses it as an input to the shell and execute the commands.

What is eval in bash script?

On Unix-like operating systems, eval is a builtin command of the Bash shell. It concatenates its arguments into a single string, joining the arguments with spaces, then executes that string as a bash command.

What is Echo eval?

eval echo \${$n} runs the parameters passed to eval . After expansion, the parameters are echo and ${1} . So eval echo \${$n} runs the command echo ${1} . Note that most of the time, you must use double quotes around variable substitutions and command substitutions (i.e. anytime there's a $ ): "$foo", "$(foo)" .


1 Answers

If it's in cmd.exe, using a temporary file is the only option [that I know of]:

python -c "print(\"Hi\")" > temp.cmd
call temp.cmd
del temp.cmd
like image 190
user1686 Avatar answered Oct 08 '22 23:10

user1686