Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

Resolved Question

Batch file input

Jul 19, 2012 12:37AM PDT

So I have a Python script which logs into a website and downloads a file. When I access the page and login, the script prompts me for a username and password. I decided to write a batch file that would send the input I need from a text file.

The batch file is simple:
@echo off
myScript.py < inputFile.txt

This successfully enters the username (which is on the first line of the txt file), but when the password prompt shows up, it doesn't enter the password. I tried a similar batch file with a simpler script that asked for two inputs, and it worked fine, so it appears it may have something to do with the fact that it's a password. Would this make sense? And how should I go about fixing this?

Discussion is locked

flyntstone92 has chosen the best answer to their question. View answer

Best Answer

- Collapse -
Can't answer.
Jul 19, 2012 1:18AM PDT
- Collapse -
I don't think you understood my question
Jul 19, 2012 1:29AM PDT

I'm not using stdin. This is strictly Python and a simple batch file. No C/C++. And I'm on Windows, which is why none of the several UNIX commands I've come across are applicable.

- Collapse -
Actually I do.
Jul 19, 2012 1:35AM PDT

I was unclear that the link was not about the redirection issue but where the folks that dig into py are.

And yes, I design and code for embedded devices that run many OSes. But since you only revealed so much of the code it seems to me that you need a py forum. That is, I would not want to guess what's amiss or what I would change in myScript.py.
Bob

- Collapse -
Problem solved
Jul 19, 2012 5:26AM PDT

I solved the issue in Python using an authentication method.