BigInsights Example KnoxShell on Windows - ibm-cloud

Trying to use the KnoxShell example from Windows (using Cmder as shell emulator). When executing the following command, the shell locks, no prompt available and nothing happend. I can only close Shell.
Is that specific to Windows?
λ gradlew.bat -q --no-daemon shell
This is a gradle Application Shell.
You can import your application classes and act on them.
import org.apache.hadoop.gateway.shell.Hadoop;import
org.apache.hadoop.gateway.shell.hdfs.Hdfs;import org.apache.hadoop.gateway.shell.job.Job;import org.apache.hadoop.gateway.shell.workflow.Workflow;import org.apache.hadoop.gateway.shell.yarn.Yarn;import groovy.json.JsonSlurper;import java.util.concurrent.TimeUnit;
===> [import org.apache.hadoop.gateway.shell.Hadoop;import org.apache.hadoop.gateway.shell.hdfs.Hdfs;import org.apache.hadoop.gateway.shell.job.Job;import org.apache.hadoop.gateway.shell.workflow.Workflow;import org.apache.hadoop.gateway.shell.yarn.Yarn;import groovy.json.JsonSlurper;import java.util.concurrent.TimeUnit;]
session = Hadoop.login( https://bi-hadoop-prod-xxxx.bi.services.us-south.bluemix.net:8443/gateway/default, user, password);
slurper = new JsonSlurper();
Groovy Shell (1.8.3, JVM: 1.8.0_51)
Type 'help' or '\h' for help.
-------------------------------------------------------------------------------
groovy:002> hadoop fs -ls /

I have tried the example on a Windows machine and it also hangs for me.
I have updated the README to state that this example does not support Windows and also added some logic to the build script to abort the example if it is being run on a Windows machine.

Related

Why does the WSL2 import command in PowerShell output "Access is denied"?

On Windows 10 Pro and 11 Pro I have installed and activated Ubuntu-20.04 and Debian. Using the documentation from MS on switching those distros to a secondary drive, everything seemed to work fine. Until the WSL import command. It outputs "Access is denied". I've tried Windows Terminal, PowerShell, and even WebStorm; I get the same output.
I am running with elevated privileges but to no avail. The export works fine, I use a different name as the source file to ensure I restore the name to its original name. The wsl.conf editing looks good, everything lines up... until the import command.
I am at a loss. I've exhausted all research. Can anyone help me resolve this so I can run these from my F: drive?
Cheers,
RN
You just have to put a filename in the end, like:
wsl --export Ubuntu C:\Users\Desktop\OneDrive\Documents\ubuntu.tar
Suppose you want to import an exported distribution "ubuntu.tar".
Try to cd at the location of the .tar file before executing the wsl --import command in PowerShell (running as standard user), for example:
PS X:\> cd D:\
PS D:\> wsl --import Ubuntu_copy .\Ubuntu_copy ubuntu.tar
Executing the wsl --import command with an absolute path didn't work for me, but the above mentioned method did.
Just in case this is an ongoing issue for anyone, you need to run wsl --import not just from an Administrator account, but you need to run Powershell/cmd as Administrator, for example by right-clicking a pwsh.exe icon/shortcut and clicking "Run as administrator". If you're running as a standard user and "Run as administrator", the import will install the distro for the admin user you've chosen to run as.
The full syntax is:
wsl --import <Distro name> <Install folder> <Source .tar file>
The import syntax is as following, you should be carefull about install dir and imported tar file's arguments order:
--import <Distro> <InstallLocation> <FileName> [Options]
Imports the specified tar file as a new distribution.
The filename can be - for standard input.
Options:
--version <Version>
Specifies the version to use for the new distribution.

Execute powershell script with gitlab-runner on local windows machine

I do have following setup:
a win PC with gitlab-runner installed (working)
a powershell script running on the same PC is starting an application
a gitlab server to connect this local PC and starting the powershell script
Now when starting the powershell script directly from the local PC, the application starts and terminates after done - working as expected. When starting the same powershell script with the gitlab server (yml-file) then I can see that the application has been started (new process in taskmanager) but it is not running as well it never terminates.
When manually end the task I see that gitlab terminates again.
Question:
what could be the root cause?
is it possible to run the powershell script with gitlab-runner? I think there is a way with the command "exec". How does the command looks like when calling the powershell script?
is it possible to run the application not in the background in order to see whats going on?
others?
thanks in advance
I think there is a bug with the gitlab runner on windows.
No matter which shell you configure in the config.toml the runner
will always use cmd.exe for an exec local run.
Specify the --shell argument to override the default cmd.exe shell:
> gitlab-runner exec shell your_job --shell pwsh
If you run this locally in your project, it outputs to .builds/, so add this to your .gitignore because git will see it and think you might want to add a submodule.

Run X11 Server (VcXsrv) from Windows Powershell

I would like to set up an X11 Server so that I can run graphical Linux applications using the Windows Subsystem for Linux (WSL 2). I have tried following the instructions on this site.
The command
choco install vcxsrv
completed successfully. But I cannot see how to start XLaunch (VcXsrv).
I already have Cygwin/X X Server installed on my machine and I am still able to launch that successfully. But when I try the following command,
PS C:\WINDOWS\system32> vcxsrv
I get the following error message,
vcxsrv : The term 'vcxsrv' is not recognized as the name of a cmdlet, function, script file, or operable program.
I have spent quite a bit of time trying to figure out how to start XLaunch (VcXsrv) without any success.
Try to look on default folder installation:
"C:\Program Files\VcXsrv\xlaunch.exe"
Try this command to run VcXsrv
xfsettingsd --sm-client-disable; xfce4-panel --sm-client-disable --disable-wm-check &
or
C:\Program Files\VcXsrv\xlaunch.exe
Refer the following link to understand VcXsrv installation and it's usage,
Running WSL GUI Apps on Windows 10

How to start WSL terminal in a current powershell directory?

I can open a powershell and type
> Ubuntu
to open a WSL ubuntu shell on windows 10. This will always take me to the WSL home directory. How would I instead open the terminal in the same location that the powershell is currently in?
FYI. I need this for creating a right click "open terminal here" type registery key for windows explorer.
If we look at what running ubuntu.exe actually does:
PS C:\> ubuntu.exe /?
Launches or configures a Linux distribution.
Usage:
<no args>
Launches the user's default shell in the user's home directory.
install [--root]
Install the distribution and do not launch the shell when complete.
--root
Do not create a user account and leave the default user set to root.
run <command line>
Run the provided command line in the current working directory. If no
command line is provided, the default shell is launched.
config [setting [value]]
Configure settings for this distribution.
Settings:
--default-user <username>
Sets the default user to <username>. This must be an existing user.
help
Print usage information.
We can see that it by default launches the WSL shell inside the home directory. If we want run inside it inside the current directory open in PowerShell, we need to specify the run option. So the full command will be ubuntu.exe run.
Another option is to just run wsl.exe or bash.exe. These commands will by default open WSL in the current working directory.
Note: We don't need to specify the .exe after the commands. Running ubuntu, wsl and bash all work as well. PowerShell knows how to run executables without specifying the extension.
method 1:
set Ubuntu to wsl default distribution by wsl --set-default Ubuntu
just type wsl and you are in the current Powershell directory
method 2:
open other folder
wsl.exe --cd $pwd or wsl.exe --cd "path"

How to Create Windows service from PERL script on Windows 7 64-bit

Does anybody have an example of how to create a windows service on windows 7 64-bit from PERL script?
On windows XP professional 32-bit, I have created windows service successfully with Win32::Daemon which has call back functions. This doesn't work on 64-bit.
I have seen this http://nssm.cc/usage and created a service using that but it doesn't keep state and it gives errors. If anybody has a proper example perhaps ...
Some idea much appreciated.
I managed to solved this now.
I now have my perl script running as a windows service now on windows 7 64-bit.
Basically win32::Daemon works on win 7 64-bit but the service creation needs to be done manually. I.e. the callback functions and start up is fine.
Here is a example to create perl windows service from scratch.
Create folder c:/myservice
Copy the code example from this link and save it to the directory above. Call it myservice.pl (http://www.roth.net/forums/topic.php?id=106)
Add these two lines after the print hello statement in the script.
$Context->{last_state} = SERVICE_RUNNING;
Win32::Daemon::State( SERVICE_RUNNING );
This is needed to keep the service running. Otherwise it stops.
Open a Dos cmd terminal in admin mode. Create service using following command
% sc create myservice binpath= "c:\strawberry\perl\bin\perl.exe"
It will display following message on success.
[SC] CreateService SUCCESS
Now we need to edit the registry. Open registry editor. (start -> then type regedit)
Find the service under HKEY_LOCAL_MACHINE->SYSTEM->CurrentControlSet->Services->myservice
Click on 'myservice' and edit the imagePath variable to be :
c:\strawberry\perl\bin\perl.exe -I "C:\myservice" "C:\myservice\myservice.pl" --run
Now open the services window and start the service. (start->control panel -> Administrative tools -> services)
In the current directory of the script a log is created and updated every couple of seconds. If using cygwin for windows, you can tail it.
% tail -f *.log
Process will print Hello! periodically ...
Thanks.