Asked by:
Can JavaScript execute via powershell?

General discussion
-
If I get a ABC.js coding, and would like to know on whether JavaScript can execute via powershell or not
Does anyone have any suggestions?
Thanks in advance for any suggestions
Thanks in advance for any suggestions
- Changed type Bill_Stewart Friday, January 26, 2018 2:45 PM
- Moved by Bill_Stewart Friday, January 26, 2018 2:46 PM Unanswerable/help vampire
Monday, November 27, 2017 4:19 AM
All replies
-
Referring to following attached image and given link, There is a that.exportFutures() function to download file, I would like to know on how to code Powershell Script to download those files.
function() {
that._exportFutures();
}
https://www.hkex.com.hk/Market-Data/Futures-and-Options-Prices/Equity-Index/Hang-Seng-Index-Futures-and-Options?sc_lang=en#&product=HSIDoes anyone have any suggestions?
Thanks in advance for any suggestions
Thanks in advance for any suggestions
- Edited by oemMicrosoft Saturday, November 25, 2017 10:56 AM
- Merged by Bill_Stewart Monday, November 27, 2017 1:39 PM Duplicate
Saturday, November 25, 2017 10:55 AM -
You will have to contact the site owners to find out how to use their site.
Please read this first: https://social.technet.microsoft.com/Forums/scriptcenter/en-US/c47b1bc2-f7fd-4d2e-8ff2-e8a81ce090d4/this-forum-is-for-scripting-questions-rather-than-script-requests?forum=ITCG
Also find scripts here: http://gallery.technet.microsoft.com/
Learn PowerShell: https://mva.microsoft.com/en-us/training-courses/getting-started-with-microsoft-powershell-8276
Script requests: https://gallery.technet.microsoft.com/scriptcenter/site/requests
\_(ツ)_/
Saturday, November 25, 2017 6:11 PM -
Just run it.<path>\abc.js
\_(ツ)_/
Monday, November 27, 2017 5:03 AM -
Referrring to following js, when I download into desktop C:\equity.js and run \equity.js under powershell, which error is occurred as shown below
Do you have any suggestions?
Thank you very much for any suggestions (^v^)
view-source:https://www.hkex.com.hk/lhkexw/js/equity.js
Thanks in advance for any suggestions
Monday, November 27, 2017 6:18 AM -
You have to use the complete path to the desktop.
Please learn how to read the error message. It tells you the exact problem. Please do not post fuzzy images. Just copy and paste text to a posting control provided on the edit bar.
\_(ツ)_/
Monday, November 27, 2017 6:32 AM -
The following function structure does not look like JavaScript at all.
JavaScript Structure : Function eTTE (id, type, name, fn){}
Following Structure : _eTTE : function(id, type, name, fn){}
Could you please give me any suggestions on what kind of language it is?
Do you have any suggestions?
Thank you very much for any suggestions (^v^)//export to excel option that.$equity_option.find(".ete").on('click',function(e){ that._eTTE('equity_option','xlsx',''+that.product+'_Options'); });
_eTTE : function(id, type, name, fn){
var that=this;
var wb = XLSX.utils.table_to_book(document.getElementById(id), {sheet:"Sheet JS"});
var wbout = XLSX.write(wb, {bookType:type, bookSST:true, type: 'binary'});
var fname = fn || name + '.' + type;
try {
saveAs(new Blob([that._s2ab(wbout)],{type:"application/octet-stream"}), fname);
} catch(e) { if(typeof console != 'undefined') console.log(e, wbout); }
return wbout;
},
Thanks in advance for any suggestions
Monday, November 27, 2017 11:12 AM -
Web browser JavaScript cannot be executed by PowerShell. JScript (also uses 'js' extension) can be executed from PowerShell.
What you have posted is browser based JavaScript. It will not execute under PS without having some sort of execution facility.
Post in a web developers forum for help.
\_(ツ)_/
Monday, November 27, 2017 1:47 PM -
Referring to following source code, I would like to know on whether it is JavaScript or JScript, since the extension is .js.
Do you have any suggestions?
Thank you very much for any suggestions (^v^)
view-source:https://www.hkex.com.hk/lhkexw/js/equity.js
Thanks in advance for any suggestions
Monday, November 27, 2017 2:57 PM -
Neither. It is likely a bit of a web page.
\_(ツ)_/
Monday, November 27, 2017 3:09 PM -
Could you please give me any suggestions on what language is bring used for coding equity.js? HTML5?
Do you have any suggestions?
Thank you very much for any suggestions (^v^)view-source:https://www.hkex.com.hk/lhkexw/js/equity.js
Thanks in advance for any suggestions
Monday, November 27, 2017 4:27 PM -
The language is JavaScript.
-- Bill Stewart [Bill_Stewart]
Monday, November 27, 2017 6:42 PM -
The code is proprietary code for the Hong Kong Exchange. It cannot be executed independently of a browser and their web sit.
\_(ツ)_/
Monday, November 27, 2017 7:04 PM -
JavaScript run on client-side, then why it cannot be implement independently under PowerShell.
Furthermore, what kind of process do they use on handling sessions? which does not seem using cookies.
Do you have any suggestions?
Thanks, to everyone very much for any suggestions (^v^)
Thanks in advance for any suggestions
- Edited by oemMicrosoft Monday, November 27, 2017 11:30 PM
Monday, November 27, 2017 11:30 PM -
Well that ia a very long story. JavaScript doe not run on Windows under the OS. It runs under a browser. PowerShell and Windows have no facilities for executing JavaScript. The JScript is a subset of JavaScript that run under WSH (Windows Script Host) which can be run from PowerShell or CMD.EXE.
JavaScript is an industry standard browser/HTML scripting language.
\_(ツ)_/
Monday, November 27, 2017 11:35 PM -
I should probably note that some JavaScript can be executed from C# and possibly under PowerShell with help.
Your script was designed to run as a web page and would not work in this mode. It is also missing at least some library API files.
If you want to play with it see this: https://stackoverflow.com/questions/4744105/parse-and-execute-js-by-c-sharp
\_(ツ)_/
Monday, November 27, 2017 11:39 PM -
If the sessions are handled by JavaScript under client-side's browser, can it be imitated and converted the process using JScript under PowerShell?
Do you have any suggestions?
Thanks, to everyone very much for any suggestions (^v^)Thanks in advance for any suggestions
Monday, November 27, 2017 11:42 PM -
See the link I just posted. You script requires a browser and other items. They all have t be resolved to the satisfaction of the web site. Contact the website to get the documentation for their web services as they likely have an API that can be used from PowerShell. We cannot help you with that. It is up to you to gather and understand how their software works. Most Securities exchanges require a special login to access data programmatically. They also do a good job of preventing anyone from gaining access using forwarded browser code. This is done to protect revenues and for security reasons.
\_(ツ)_/
Monday, November 27, 2017 11:48 PM -
Could you please give a general description on how HKEX handles sessions? and what make it difficult to imitated and converted the process under PowerShell?
Do you have any suggestions?
Thanks, to everyone very much for any suggestions (^v^)Thanks in advance for any suggestions
Tuesday, November 28, 2017 2:31 AM -
No. You have to ask the vendor for that information. We cannot help you.
\_(ツ)_/
Tuesday, November 28, 2017 3:37 AM -
This is not the right forum for "how do I retrieve data from a specific web site" questions. You need to ask the owners/developers of that web site your questions.
-- Bill Stewart [Bill_Stewart]
Tuesday, November 28, 2017 1:27 PM