[Show all top banners]

shree5
Replies to this thread:

More by shree5
What people are reading
Subscribers
:: Subscribe
Back to: Kurakani General Refresh page to view new replies
 php/java help please -shreeFive
[VIEWED 1982 TIMES]
SAVE! for ease of future access.
Posted on 01-02-06 7:58 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Any help would be highly appreciated.

Please advise me on the strategy itself or help me shooot out a few troubles.

I have to transfer a file from a Windows machine to a Linux web (Apache) server. The
windows machine monitors/measures something and has to send the data to the server;
the concept is to be able to access that information almost "live" through the web. So,
the file-transfer thing has to be unattended and also recurring on a preset interval, say
every 10 mins.

My "latest" plan is to,
1. Create a web-page on the server that processes the file-upload from a trusted domain.
(this one done- fine with PHP). lets say: "pull.php"
2. Schdule (windows task scheduler) to invoke that URL address and pass the file as the
parameter. For this, I am scheduling a windows script (lets say, "push.vbs"- this one done)
that LOCALLY creates a html-form (lets say "upload.htm") on the fly which is auto-submitting
on the "body-onLoad" event to the (POST method) "pull.php" on the remote web server.
The form has a "file" input type, the value of which is the file that i want to pass on to the web
server.

Whenever my script is run, a browser window opens (for the local "upload.htm" created
on-the-fly). I can only shell-launch a job from windows scripts. Every hour, there are six browser
windows open.
Ques: Is there any way to invoke/excite/execute a URL without opening a browser window?

Then, I thought of redirecting. The local "upload.htm" will call "pull.php" on the server which will
redirect it to a "bye.htm" that publishes some javascript to kill the current window.
Ques: Is there any javascript means to kill the current window that is not opened by the javascript
itself? I played with self.close() and likewise stuffs but that again shows a confirmation alert like
"do you want to close the window?" before the window can actually be closed. (default browser is
IE in XP-Pro SP2)

OR,
Is there any means of unattended http-type file upload to a server from a windows machine? Or
any means that can be scheduled? (FTP not pref)

Thanks in advance

Please make me keep rolling...
 
Posted on 01-02-06 8:01 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

सुधारेर फेरि पोष्ट गरेको,

Any help would be highly appreciated.

Please advise me on the strategy itself or help me shooot out a few troubles.

I have to transfer a file from a Windows machine to a Linux web (Apache) server. The windows machine monitors/measures something and has to send the data to the server; the concept is to be able to access that information almost "live" through the web. So, the file-transfer thing has to be unattended and also recurring on a preset interval, say every 10 mins.

My "latest" plan is to,
1. Create a web-page on the server that processes the file-upload from a trusted domain. (this one done- fine with PHP). lets say: "pull.php"
2. Schdule (windows task scheduler) to invoke that URL address and pass the file as the parameter. For this, I am scheduling a windows script (lets say, "push.vbs"- this one done) that LOCALLY creates a html-form (lets say "upload.htm") on the fly which is auto-submitting on the "body-onLoad" event to the (POST method) "pull.php" on the remote web server. The form has a "file" input type, the value of which is the file that i want to pass on to the web server.

Whenever my script is run, a browser window opens (for the local "upload.htm" created on-the-fly). I can only shell-launch a job from windows scripts. Every hour, there are six browser windows open.
Ques: Is there any way to invoke/excite/execute a URL without opening a browser window?

Then, I thought of redirecting. The local "upload.htm" will call "pull.php" on the server which will redirect it to a "bye.htm" that publishes some javascript to kill the current window.
Ques: Is there any javascript means to kill the current window that is not opened by the javascript itself? I played with self.close() and likewise stuffs but that again shows a confirmation alert like "do you want to close the window?" before the window can actually be closed. (default browser is IE in XP-Pro SP2)

OR,
Is there any means of unattended http-type file upload to a server from a windows machine? Or any means that can be scheduled? (FTP not pref)

Thanks in advance

Please make me keep rolling...
 
Posted on 01-02-06 11:13 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

One of a number of things you could do:

1. Schedule the Windows task as a different user than yourself. When the user is not logged in, Windows will have no access to the console to display the UI. That may avoid the windows popping up. I haven't tried this myself...just a theory, see if it works. It should.

OR

2. At the end of your existing vb script, or bat file, stick a line that invokes this shell command:
TASKKILL /f /im "iexplore.exe"

That should kill all Internet Explorer process windows. It may work in a fully automated scenario when you have no other iexplore windows open. Otherwise you risk closing your own sajha.com window ;-)

OR

3. There is a way to make an HTTP request without invoking the browser. Include this in your vbscript:

 
Dim http
Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
http.Open "GET", "http://www.sajha.com/sajha/html/openforum.cfm?forum=2" 'put your own url + querystring there
http.Send

'# just for debugging... you can take these lines out when you put it in production...
Dim s
s = http.ResponseText
wscript.echo s


Let me know how it goes. Good luck.
 
Posted on 01-02-06 1:09 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Echoes,
Thank you very much.

It was the third method that I was looking for. Once I knew about the Httprequest object, I googled and found a canned solution at,

- http://www.motobit.com/tips/detpg_post-binary-data-url/

सबै गरिदिएको आफूलाई चाहिने जस्तै कोड भेटियो। आज दिन भरमा तेही गरम्ला भन्ठानेको, अब आजलाई पुग्यो । भोलि तिर टेस्ट गरौँला, काम गरेछ भने ठीकै छ, नगरे फेरि यही साझामा आएर किचकिच गरम्ला ।

Thanks a lot

Keep rolling...
 
Posted on 01-02-06 1:25 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Good. I'm glad it worked out for you. Happy Programming!
 
Posted on 01-02-06 9:46 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Echoes -jee,

So learnt that, with the Httprequest object, the following methods should be executed
.Open "POST",
.SetRequestHeader
.Send

For requestheader, i found a few examples like -
...
Example#1

' Grab the file
nFile = FreeFile
Open StrFileName For Binary As #nFile
strFile = String(LOF(nFile), " ")
Get #nFile, , strFile
Close #nFile

' Assemble an HTTP request.
WinHttpReq.Open "POST", strURL, False

' Set the header
WinHttpReq.SetRequestHeader "Content-Type", "multipart/form-data; boundary=Xu02=$"

' Assemble the body
strBody = "--Xu02=$" & vbCrLf & _
"Content-Disposition: form-data; name=files; filename=" & vbCrLf & _
"Content-type: file" & vbCrLf & vbCrLf & _
strFile & vbCrLf & _
"--Xu02=$--"

' Because of binary zeros, post body has to convert to byte array
aPostBody = StrConv(strBody, vbFromUnicode)

' Send the HTTP Request.
WinHttpReq.Send aPostBody


...Another one, simply
Example#2

/ Initialize an HTTP request.
WinHttpReq.Open("PUT", "http://postserver/newdoc.htm", false)

// Post data to the HTTP server.
WinHttpReq.Send("Post data")


For me, both would work because my file is a plain text file. However, I got stuck for,

1. With the former approach, it looks like it is reading the file into a byte array- i guess vbscript does not quite encurage that straightly. And I can't understand what the "boundary" in the request-header is.

2. With the second approach,
WinHttpReq.Send("Post data"), looks neat and hot. The contents of my file can be the "Post data" inside the brackets.

BUT,
How do I retrieve them in the server-side php? With regular POST or GET, there used to be variable-names to the data, right? Those $_POST[xxxx] kind of things?

I mean, how do I access the post data in the server-side for this cool object?

Any ideas please???

Thanks in advance
 
Posted on 01-02-06 10:17 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

well, the 'put' verb writes the file. you shouldn't have to do anything on the server side. except enabling the 'put' verb... it's probably disabled by default. that should be all.

so for example, if you make a 'PUT' request to http://localhost/fileA.html, (with the binary data sent via the argument to .Send()) then this request actually writes the file 'fileA.html' under your webroot (wherever localhost is pointing to) with the binary data sent...

you shouldn't have to parse the binary data on the server side. that should all be taken care of by the server.
 
Posted on 01-02-06 11:18 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

एउटी आईमाईले खोलामा नाङ्गै नुँहाउदै गरेकी रहिछन्, ठ्याक्कै उनका जेठाजु आई पुगेछन्। हतपत के पाईन्छ लाज छोप्न भनेर खोज्दा एउटा एक हात गज भएको तौलिया (towel) भेटिछन्। अनि जेठाजु को अगाडि तेही तौलिया ले आफूलाई छोप्न खोजिछन्। माथिको भाग छोप्न खोजे तलको देखिनी, तलको छोप्न खोजे माथिको देखिनी, बिजोग भएछ उनको । धन्न कसो कसो बुद्धि आएछ र आफ्नो पछाडिको भाग चाहि जेठाजु तिर फर्काईछन र तौलिया चाहि ढाडमा बेरिछन्।

Echoes - jee, मेरो नि तेस्तै हालत भयो क्या । मेरो सर्भर लिनक्स माथि बसेको Apache हो, php मा जे गरे नि पाईन्छ, बाँकी कहाँ छ त्यो सर्भर भन्ने नि थाहा छैन । भनेसि PUT enable गर्ने मेरो वसमा रहेन ।

ती आईमाईले त बरु पछाडि तिर फर्केर लाज जोगाईन, म चाहि कता फर्किनी हो खै ? लौ न केही भये सुझाई पाउँ है ।

NB: म पुरुषै हुँ है, फेरि बित्थामा जत्था पछि लाग्ला। यो ठाउँमा त तेस्तो नि हुने ग-याछ, एउटा फुला परेको (flip flop) लाई को को ले खेदिराका थिए अस्तिन कहिले हो ।

Keep rolling...
 
Posted on 01-02-06 11:54 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

नभन्दै जेठाजु आए ल उता बाट ,

 
Posted on 01-03-06 3:59 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

बल्ल बल्ल रातभरिमा जेठाजुलाई नि पार लाईयो, thought might be useful to others too!!!
Requesting vbs is,
 
Option Explicit
Const WinHttpRequestOption_EnableRedirects= 6
Dim http, url, strPostData

' Initialize an HTTP request.
Set http = CreateObject("WinHttp.WinHttpRequest.5.1")

url = "http://www.ice.ucalgary.ca/iceload/online/pull_1.php"
strPostData = "basasthan=sajha&kamjati=khattam"

With http
.Option(WinHttpRequestOption_EnableRedirects) = False
.Open "POST", url
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"
.Send strPostData
End With

'# just for debugging... you can take these lines out when you put it in production...
Dim s
s = http.ResponseText
's=http.GetAllResponseHeaders
wscript.echo s


The server php and the result of the execution are,

KEEP ROLLING :-)

 
Posted on 01-03-06 4:33 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

"यो ठाउँमा त तेस्तो नि हुने ग-याछ, एउटा फुला परेको लाई को को ले खेदिराका थिए अस्तिन कहिले हो"....Grrrrr

"जुन पोइ होला जस्तो छ त्यही जेठाजु" हुनTथाल्यो भने ढाक्ने र छोप्ने नै किन गर्नुपर्यो र भनेको ? :D

जे होस्, यो programming मेरो बिषय परेन है ! विना अर्थै प्याच्च बिचमा बोलेकोमा रिसानि माफ पाऊँ !
 
Posted on 01-03-06 9:44 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Great... that's probably better anyway. Using PUT over HTTP can be a security loophole...You can think of it as an FTP PUT... just a diff. protocol and often even weaker.

BTW, you might want to check the IP of the client (or the presence of something) to make sure no unintended user is submitting form/post data to your application, particularly, now that you've made the URL available for everyone in the world to see...

Also, your data is being transmitted unencrypted. You may want to use SSL if it contains sensitive information...

Happy Programming!
 


Please Log in! to be able to reply! If you don't have a login, please register here.

YOU CAN ALSO



IN ORDER TO POST!




Within last 90 days
Recommended Popular Threads Controvertial Threads
शीर्षक जे पनि हुन सक्छ।
NRN card pros and cons?
What are your first memories of when Nepal Television Began?
TPS Re-registration
Democrats are so sure Trump will win
Basnet or Basnyat ??
nrn citizenship
Sajha has turned into MAGATs nest
Nas and The Bokas: Coming to a Night Club near you
डीभी परेन भने खुसि हुनु होस् ! अमेरिकामाधेरै का श्रीमती अर्कैसँग पोइला गएका छन् !
3 most corrupt politicians in the world
if you are in USA illegally and ask for asylum it is legal
Top 10 Anti-vaxxers Who Got Owned by COVID
आज बाट तिहारको सेल सकियो
निगुरो थाहा छ ??
Travelling to Nepal - TPS AP- PASSPORT
Why are democrats allowing hundreds of thousands of illegal immigrants across the border
Poonam pandey - death or suicide?
ढ्याउ गर्दा दसैँको खसी गनाउच
Doctors dying suddenly or unexpectedly since the rollout of COVID-19 vaccines
Nas and The Bokas: Coming to a Night Club near you
NOTE: The opinions here represent the opinions of the individual posters, and not of Sajha.com. It is not possible for sajha.com to monitor all the postings, since sajha.com merely seeks to provide a cyber location for discussing ideas and concerns related to Nepal and the Nepalis. Please send an email to admin@sajha.com using a valid email address if you want any posting to be considered for deletion. Your request will be handled on a one to one basis. Sajha.com is a service please don't abuse it. - Thanks.

Sajha.com Privacy Policy

Like us in Facebook!

↑ Back to Top
free counters