Is there a way to execute system commands from within nightwatch? - nightwatch.js

I am looking to start some service using the command line tool from within the nightwatch. Searched a lot over the internet but found nothing related.
Appreciate if someone can provide an example to execute system commands.

You need to run the code using NodeJS code and definitely not NightwatchJS. I have noticed that you are trying to execute it using client.excute(). Please note that this runs in the browser and not in the system. You should explicitly run your system code using NodeJS and outside Nightwatchjs commands.

Related

How to start Apache nifi 1.17.0?

I've downloaded Apache nifi 1.17.0 and tried to start it by bin/run0nifi.bat, but it didn't work. When I click on it window open and disappear in the same time.
I'm working on windows 11 pro
What should i do?
I tried to start it by console and tried to start 1.19.1 and unfortunately it didn't help
I'm a beginner so I might not have done some obvious things
Thx for help)
You need to do two things first of all:
you need to make sure that you have installed JAVA on your machine and set the PATH for the JDK in the Environment Variables (JAVA_HOME).
If JAVA is configured correctly you need to open CMD and go within the NiFi Folder. From there, you should execute the run-nifi.bat manually and see if anythings gets written in the CMD window.
Besides that, you can go within the logs folder and see if any logs are being generated. Most likely you will find something in the nifi-app.log.

How to chain alias commands in cmder

I love using aliases on my ubuntu server for repeated commands as they're a huge timesaver and they're absolutely irreplaceable for me now.
I've been using cmder a lot recently on Windows as it is the best console replacement for windows that I know of. It is a wonderful piece of software and I have almost all the basic bash commands including aliases.
However, I cannot find a way to chain multiple alias commands. I've tried delving into doskey at this link Microsoft DOSKEY and the macros without any luck.
So, basically I want to create multiple aliases. For e.g.
alias loginuser1='ssh -i ~/user1keyfile user1#$s'
alias mynewcloudserver='901.801.701.601'
and want to be able to login by typing:
loginuser1 mynewcloudserver
loginuser5 mytestingcloudserver
I have currently tried this:
loginuser1 mynewcloudserver
which produces this error:
ssh: Could not resolve hostname mynewcloudserver: no address associated with name
I get that this is because it is probably looking in my hosts file for mynewcloudserver and is unable to find an entry. I am able to login by doing this instead:
loginuser1 901.801.701.601
which brings us to my problem. I am unable to call one alias from another alias
I know the above might not be the best way to create those aliases, but I just want to understand the logic and how to chain aliases together in cmder which will open up a host of possibilities pun intended.
If anyone can help me out, that would be great.
The only option I've found is to create a myscript.sh file with the commands, and create an alias to call the file.
It may be helpful to include wait between commands if they need to finish before the next one runs.
The first time you run it, it may ask you which program to use. Choose Git for Windows.

Jenkins Timeout because of long script execution

I have some Issues regarding Jenkins and running a Powershell Script within. Long Story short: the Script takes 8x longe execution time then running it manually (takes just a few minutes) on the Server(Slave).
Im wondering why?
In the script are functions which which invoke commands like & msbuild.exe or & svn commit. I found out that the script hangs up in those Lines where before metioned commands are executed. The result is, that Jenkins time out because the Script take that long. I could alter the Timeout threshold in the Jenkins Job Configuration but i dont think this is the solution for the problem
There are no error ouputs or any information why it takes that long and i do not have any further Idea for the reason. Maybe one of you could tell me, how Jenkins invokes internaly those commands.
This is what Jenkins does (Windows batch plugin):
powershell -File %WORKSPACE%\ScriptHead\DeployOrRelease.ps1
I've created my own Powershell CI Service before I found that Jenkins supports it's own such plugin. But in my implementation and in my current jobs configs we follow sample segregation principle rule: more is better better. I found that my CI Service works better when is separated in different steps (also in case of error it's a lot easy for a root cause analyse). The Single responsibility principle is also helpful here. So as in Jenkins we have pre- & post-, build and email steps as separate script. About
msbuild.exe
As far as I remember in my case there were issues related with the operations in FileSystem paths. So when script was divided/separated in different functions we had better performance (additional checks of params).
Use "divide and conquer" technique. You have two choices: modify your script so that will display what is doing and how much it takes for every step. Second option is to make smaller scripts to perform actions like:
get the code source,
compile/build the application,
run the test,
create a package,
send the package,
archive the logs
send notification.
The most problematic is usually the first step: To get the source code from GIT or SVN or Mercurial or whatever you have as version control system. Make sure this step is not embeded into your script.
During the job run, Jenkins capture the output and use AJAX to display the result in your browser. In the script make sure you flush standard output for every step or several steps. Some languages cache standard output so you can see the results only at the end.
Also you can create log files that can be helpful to archive and verify activity status for older runs. From my experience using Jenkins with more then 10 steps requires you to create a specialized application that can run multiple steps like "robot framework".

What is the Cloud-Init equivalent for Windows?

It seems that the stock bootstrapping process is a bit lacking on Windows.
Linux has cloud-init which will install packages, store files, and run a bash script from user data.
Windows has ec2config but there is currently no support to run a cmd or powershell script when the system is "ready"--meaning that all the initial reboots are completed.
There seem to be third party options. For example RightScale has the RightLink agent which performs this function.
Are there open source options available?
Are there any plans to add this feature to Ec2Config?
Do I have to build this my self?
Am I missing something?
It appears that EC2Config on the Amazon-provided AMIs now supports "User Data Scripts" as of the 11-April-2012 updates.
The documentation has not yet been updated, so it's hard to tell if it supports PowerShell or just cmd.exe scripts. I've posted a question on the AWS forums to try and get some more detail, and will update here when I learn more.
UPDATE: It looks like cmd.exe batch syntax is supported, which can in turn invoke PowerShell. There's a new version of the EC2Config documentation included on the AMI. Quoting from it:
[EC2Config] will read in the user data specified for the instance and then check if it contain the tags <script> and </script>. If it finds both then it will take the information between those two tags and save it to a batch file located in the Settings folder of this application. It will then execute the batch file during the start of an instance.
The batch file will only be created and executed on the first launch of an instance after a sysprep. If you want to have the batch file created and executed again set the Ec2HandleUserdata plugin state to Enabled.
UPDATE 2: My interpretation is confirmed by Shon from the AWS Team
UPDATE 3: And as of the May-2012 AMIs, PowerShell is supported using the <powershell/> tag.
Cloudbase.it have opensourced a python windows service they call cloudbase-init which follows the configdrive and HTTP datasources.
http://www.cloudbase.it/cloud-init-for-windows-instances/
github here
https://github.com/stackforge/cloudbase-init/
I had to build one myself however it was very easy. Just made a service that reads the user-data when starts up and executes the file as a powershell script.
To get around the issue of not knowing when to start the service I just made the service start type as "delayed-auto" and that seemed to fix the problem. Depending on what you need to do to the system that may or may not work for you however in my case that was all I had to do.
I added a new codeplex project that already has this tool built for windows. Looking forward to some feedback.
http://cloudinitnet.codeplex.com/
We had to build it ourselves; we did it with a custom service and built our own AMIs. There's no provision currently within EC2Config to do it.
Even better, there is no easy way to determine when the instance is "ready". We had to do it by tailing the logfile of EC2Config.
I've recently found nssm (at nssm.cc) which easily wraps a simple batch file (or pretty much anything else) as a service. You can then us sc config servic1 depend= service0 to force the batch file to be run at a particular point in the service initialization sequence. I am using it in between ex2config and sql express to create a folder on d, for instance. You'll have to use the services tool to make it run as network services and change the AppExit property to Ignore using regedit, but it works once you get it all in place.

How to write an automated script to install a new cms

Does anyone know where I would begin to write an automation script to install a CMS to my wwwroot folder and create the database for it? For this round it would be for DNN on in a windows environment.
I am looking for methods to speed up our development process in the office.
Many thanks!
First write a (textual) script of what you need to do.
Then convert these steps to automated steps.
The exact steps depend on the database and webserver you are using and on how you want everything to be configured, so get these steps clear before you start scripting.
Queries you need to execute can be put in separate files (usually with .sql extension). Most databases allow running those files from the command line.
Most other commands, like creating folders and such can be run from the command line as well. If you can run it in the command window, you can put it in a batch file as well to run everything at once, so you can translate all possible steps to a line (or group of lines) in a .bat script.
Identify the prerequisites, and generally they windows patches, db/sql server etc.
Determine how to install all the prerequisites from the command line.
Create your database manually and then script it out using something like sql server management studio or a third party tool such as the RedGate Sql Tool Belt.
Read up on how to install the CMS from the command line
Automate the installation of the above using a script language, such batch, Powershell, VB script etc.
Once you've got to step 5 you can ask more specific questions on particular aspects of this.

Resources