Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 313 Vote(s) - 3.54 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sending arguments from Batch file to Python script

#1
I'm running Python 3.2 on Win XP. I run a python script thru a batch file via this:

`C:\Python32\python.exe test.py %1`

`%1` is an argument that i pass to do some processing in the python script.

I have 2 variables in the batch file that I also want to send as arguments to the python script.

`set $1=hey_hi_hello`

`set $2=hey_hi`

I want to be able to do something like this if possible:

`C:\Python32\python.exe test.py %1 $1 $2`

And then retrieve these argiments in the python script via `sys.argv[2]` and `sys.argv[3]`


Would appreciate any help with this. Thank you.
Reply

#2
your_script.bat:

set VAR_1=this
set VAR_2=that

python your_script.py %1 %VAR_1% %VAR_2%
Reply

#3
Another option is to write arguments right after the python script, following the example:

`python your_script.py this that`

If you are using Linux `.sh` file, remember to run `dos2unix XXX.sh` before you run:
`bash XXX.sh`.

The reason, in a simple version, is that dos and unix use different newline breakers.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through