Log on to we page via script or batch file

We have a process controller in our shop which stores records sent by our shop equipment...
It is web page accessible on the LAN and has a simple JavaScript logon. I need to be able to log on to this site (I have the username and password) via a script or batch file, as I have been tasked with pulling the text records it stores automatically. Since all the records resolve the HTML addresses this is simple, once logged on... However I can't seem to find a good way to do this. The old http://user:password@somesite.com/URL doesn't work. Anyone know how to go about this? Thanks.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris StanyonWebDevCommented:
Don't really have enough to go on here.

You say your records are 'stored' but don't say how. If they're stored in a database, then you can probably skip the web page completely and just access the records directly using something like PHP.

If your system uses Javascript for a login then it probably isn't very secure. Normally, your login details are sent to the server using POST. If that's the case, then you could use a cURL request, again using something like PHP to POST the credentials and pull back your data.

The old user:password@somedomain.com only ever worked for htpasswd protected folders.

Probably need more info to give you a specific answer.
JP_TechGroupAuthor Commented:
No question the page is not very secure... It's what the client system runs on however, so there isn't much I can do about that.

ok, here is the script I am trying to make work... it runs correctly except the authentication does not work. The resulting file download winds up being the html for the start page rather than the file to be downloaded... obviously the script is not properly authenticating.

 strLink = "http://ourURL/StorageCardMMC/LOG_P1/LOG_P10.txt"
 	 ' Get file name from URL.

 	 strSaveName = Mid(strLink, InStrRev(strLink,"/") + 1, Len(strLink))
 	 strSaveTo = "C:\temp\" & strSaveName
     ' Create an HTTP object
     Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" )
     ' Download the specified URL
     objHTTP.Open "GET", strLink, False
     objHTTP.SetCredentials "username", "password", HTTPREQUEST_SETCREDENTIALS_FOR_SERVER
          Set objFSO = CreateObject("Scripting.FileSystemObject")
	  If objFSO.FileExists(strSaveTo) Then
	  End If
      If objHTTP.Status = 200 Then
    	Dim objStream
	    Set objStream = CreateObject("ADODB.Stream")
	    With objStream
		    .Type = 1 'adTypeBinary
		    .Write objHTTP.ResponseBody
		    .SaveToFile strSaveTo
	    End With
	    set objStream = Nothing
	  End If
	  If objFSO.FileExists(strSaveTo) Then
	  End If 

Open in new window

Chris StanyonWebDevCommented:
Hi JP,

My point was that if your security is JavaScript-based then it can probably be bypassed altogether. Javascript security is usually ineffective because it's browser based so can be turned off (or avoided completely). If you try to access that txt file without logging in first, and you end up on a different page, then I'm guessing there is more to your logon system than just Javascript.

What happens if you disable javascript in your browser and try accessing the file?

If you're able to run PHP scripts, then a simple cURL request may do the job for you:

$remoteFile  = 'http://ourURL/StorageCardMMC/LOG_P1/LOG_P10.txt';
$newFile = 'LOG_P10.txt';
$fp = fopen($newFile, 'w');
$ch = curl_init($remoteFile);
curl_setopt($ch, CURLOPT_FILE, $fp);
$data = curl_exec($ch);

Open in new window

The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

JP_TechGroupAuthor Commented:
Thank you and apologies for taking so long to respond. The PHP script yields the same result. Think this one is over my head!
Chris StanyonWebDevCommented:
Hmmm. It sounds like your security model is more than just Javascript (which is a good thing), but in order to log in remotely, you'll need to understand a little more about how it's implemented.

If your security is server-side controlled, and relies on a user to fill in and POST a form, for example, then you may be able to do this using cURL. Before you try moving further on this though, I would suggest you get a good handle on the authentication model used. Without that, it will just be trial and error

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Chris StanyonWebDevCommented:
JP_TechGroupAuthor Commented:
This was an oops on my part Chris. I have notified the mod and asked to have the solution upgraded to A.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.