Presentation is loading. Please wait.

Presentation is loading. Please wait.

Executing Host Commands

Similar presentations


Presentation on theme: "Executing Host Commands"— Presentation transcript:

1 Executing Host Commands
MIS 3406 Department of MIS Fox School of Business Temple University

2 Why Execute Host Commands
Why would you want to execute host commands within code? Automate repetitive tasks Moving data Monitoring systems Backups DevOps Automated operations Automated testing Automated migration of code and data Dev  QA  Prod

3 What do you need to be able to do?
Execute a command Capture and process the output Stdout – Stderr – Capture the “Exit Code” (a.k.a. “Return Code”) Conditional execution of code based on results of the host command

4 Execute a command at the command line…
Arguments 1, 2 and 3 stdout

5 Let’s execute it within NodeJS…
Setup .spawnSync stdout Command Arguments 1, 2 and 3 stderr Exit Code

6 How about a bad command…
Setup .spawnSync stdout Command Arguments 1, 2 and 3 stderr Exit Code

7 OS Command (not a .exe) – Windows Only
Arguments Need a Shell stdout stderr Exit Code

8 HostCommandWithExe.js Get your first program running that executes a host command with an exe.

9 HostCommandWithoutExe.js Get your first program running that executes a host command without an exe.

10 Challenges MyPing MyDir WhoAmI MyHostName MyIPAddress LookupIPAddress


Download ppt "Executing Host Commands"

Similar presentations


Ads by Google