How to remotely control Trace32 via Terminal - linux

I have an automated Linux agent (CentOS) with Bamboo to aid in building and deployment of new software onto a board. I want to be able to run .cmm files via Trace32 and a Lauterbach onto my locally located board using the remote Bamboo agent to trigger daily builds and deployment.
I am aware of the terminal command option: ./trace32 -s file.cmm to avoid using the GUI.
Is there anyway I can use this kind of thing for remote deployment, perhaps utilising ssh?

There is no SSH server in TRACE32. However you can control TRACE32 remotely via the TRACE32 remote API. See the document "api_remote.pdf" in the PDF folder of your TRACE32 installation.
To launch some scripts or execute some simple commands from a bash shell, you can use the command line tool t32rem from the <t32>/bin/linux folder.
This tool uses the TRACE32 remote API to send TRACE32 commands to open TRACE32 GUIs.
Do the following:
Enable the TRACE32 remote API to add the following two lines to your TRACE32 configuration file (usually "config.t32")RCL=NETASSIST
PORT=20000 You have to ensure that there is an empty line before and after these lines in your configuration file.
Launch TRACE32 and send a command to it with t32rem like that: t32rem localhost port=20000 <command> For <command> you can choose any TRACE32 command like DO file.cmm to execute your mentioned PRACTICE script.
For more complex remote control of TRACE32 (e.g. from a Python script) you should have a look at the previously mentioned "api_remote.pdf" and the examples at <t32>/demo/api.

When you already have a command to run, how about using a Script task in your plan, so that you can execute the command you wanted?

Related

What is the best method to execute script on remote via Jenkins

Am looking for the best & proper method to execute script on remote via Jenkins job.
What is better:
Write the commands directly on the Jenkins "Exec command" label on the "Send files or execute commands over SSH" tab.
Just copy a bash file to the remote and execute it through Jenkins "Exec Com.." label command.
The reason I'm asking this question is because I am struggling with the second approach (i.e. execute local file which located on the remote...) and thinking maybe that not the best practice.
In addition, should I execute the script using sudo (because running as sudo causes me gitlab issues when try to clone..).
And when I am execute the the script he ask for password.
So far added permissions to /etc/sudoers not do the job but I'm thinking maybe that's a tab/lines issue...possible ?
Any suggestions ?
I personally would go for SSH protocol approach (Simple, secure and reliable). Moreover, there are some plugins already made for those use cases you've mentioned.
1. SSH plugin
You can use the SSH Plugin to run shell commands on a remote machine
via ssh.
So this plugin would fit into your first option of executing script or commands on remote via SSH.
2. Publish Over SSH Plugin
The goal of the Publish Over plugins is to provide a consistent set of
features and behaviors when sending build artifacts ... somewhere.
The Publish over SSH plugin will allow you copy files to a remote server and execute arbitrary commands on the remote server. So this fits into your second approach where you want to first copy script and then execute.
Really you can use any of those plugins (Both use SSH so it's more secure). The question is what suits you the most. Choose wisely :)

Kudu Debug console Bash vs SSH

In Azure when using a Application Service on Linux (Node) there is a menu on top of Kudu: Debug console.
"Debug console" has to choices: Bash and SSH.
What is the difference between them?
It looks like they follow to different environments.
Bash is a popular text-based shell and command-language. It is the default shell included within Ubuntu and other Linux distros, and in macOS. Users type commands into a shell to execute scripts and/or run commands and tools to accomplish many tasks.
You can use bash scripts for your deployment. Note that on Linux, bash scripts must have Unix-style (LF) line endings.
You can check the Git example for your reference.
If you use the Bash console in Advanced Tools (Kudu) to look at environment variables, you won't see environment variables that you set using App Settings. That's because the Bash console runs in a separate context from your Web App. In order to see your environment variables, use SSH to access your container.
Secure Shell (SSH) is commonly used to execute administrative commands remotely from a command-line terminal. App Service on Linux provides SSH support into the app container with each of the built-in Docker images used for the Runtime Stack of new web apps.
Whether you're a Windows user, a macOS user, or a Linux user, you can easily SSH into your Web App by accessing Kudu -> Debug Console -> SSH
You may want to check the documentations Web Apps and SSH and Things You Should Know: Web Apps and Linux for more details.
Hope this helps.

Installing SoapUI on Amazon AMI Linux command line

I need to install and run SoapUI on linux OS (Amazon AMI linux).
This is a command line version (no GUI)
I was able to successfully download and unzip SoapUI tar using the below commands
Download SoapUI installation files
wget http://freefr.dl.sourceforge.net/project/soapui/soapui/5.0.0/SoapUI-5.0.0-linux-bin.tar.gz
Extract Contents
tar -xzf SoapUI-5.0.0-linux-bin.tar.gz -C /opt/
Install SoapUI
cd /opt/SoapUI-5.0.0/bin/
After this when i run the following command:
./soapui.sh
I get below exception
java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:207)
at java.awt.Window.<init>(Window.java:535)
at java.awt.Frame.<init>(Frame.java:420)
at javax.swing.JFrame.<init>(JFrame.java:218)
at com.eviware.soapui.SoapUI.startSoapUI(SoapUI.java:842)
at com.eviware.soapui.SoapUI$SoapUIRunner.run(SoapUI.java:697)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:312)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:745)
at java.awt.EventQueue.access$300(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:706)
at java.awt.EventQueue$3.run(EventQueue.java:704)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:715)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.r...(EventDispatchThread.java:91)
Is there something missing here or any other commands needs to be called ?
SoapUI itself is a graphical tool, and the main application isn't going to like running without a graphics display.
When I've run the SoapUI stuff on a Linux server without X11, it's been the mock service facility that I'm after - I use it to provide substitute SOAP or REST services for automated testing etc.
The mock service runner runs well without an X11 server - you just have to tell java not to look for a graphical user interface.
So you add -Djava.awt.headless=true to the command line:
./mockservicerunner.sh -Djava.awt.headless=true
If you just to that it will give you a 'help' output, because this tool is designed to use an existing SoapUI project file to provide preconfigured responses, rather than for interactive use.
The alternative is to use X-Forwarding, so SoapUI runs on your server, but the UI is displayed on your local workstation. I've never done that (because, as I said, I'm after the standalone interaction for automated testing), but this page has some detail: http://blog.ashwani.co.in/blog/2013-01-10/soapui-mockservicerunner-on-linux-without-x-config/
(it also mentions the 'headless' option for mockservicerunner.sh.
This page has some detail about setting up a project in SoapUI first before using it for one of the automated tools (loadrunner in this case): http://www.soapui.org/load-testing/command-line-execution.html
I just installed and executed SoapUI in AWS (Red Hat) without using any graphical interface:
1.- Download SoapUI directly from soapui.org; search for the latest Linux version, copy the link address and download the software into any Linux directory using the wget command. This should have downloaded an installation script file (for example, SoapUI-x64--5.3.0.sh).
2.- Execute the previous installation script from command line and answer the installation prompts. Once you have finished go to the directory where you elected to install it and verify that you have all the folders and files (bin, lib, etc.).
3.- To run SoapUI from the command prompt, go to your SoapUI home directory and execute an instruction like this:
sh bin/testrunner.sh -s"Your Suite Name" -c"Your Test Case Name" -f/your/output/path/ /your/project/path/your-soapui-project.xml

How To Run a Script in WinSCP

I am using winSCP GUI to connect to linux terminal and then copy the files and other stuff.
Now i have some scripts on the UNIX server,I am connected but how to run the script from the Win SCP.
what basically is needed is
sh scriptname.sh through the WinSCP.Please let me know if anyone else found out how to do that.AS loging into putty and running the command is time taking for me.
WinSCP Custom Command option tried to click on Execute,but the error pops up like no such directory.
Tried google but to the point information is not coming up.
Try this
sh "!"
OR
First of all executing commands from WinSCP can be tricky and if you are able to run few commands also,there are restrictions which you can not do fro WinSCP and should have to ultimately take help of PUTTY.
Here is the link Integrate WinSCP with Putty which will help you integrate your WinSCP to Putty,so that when you open any server through WinSCP putty will automatically connect without even asking for the password.And then you can run you command,hope that wound be of any trouble to you.
Remember you can store the connection details in WinSCP and in just one click it will connect to the server on SCP and also on Putty.
You can define your own custom command by right-clicking, selecting Custom commands and selecting Customize. Then click "Add", enter a description, e.g. Run and specifying a custom command. Try sh "!" to start with - that works ok for me, if you still get errors post your output back here. The quotes are important - only the exclamation should be quoted.
Right click the script > Custom Commands > Execute
Hope this helps.
To execute an ad-hoc shell command in WinSCP, use the Console window:
To execute the shell script selected in a file panel, create a custom command like:
sh "!"
This is actually, what the pre-defined custom command Execute (almost) does.
I'm aware that you claim that this does not work. But it should work in general. If you are having problems, please tell us details (exact error message, screenshot, anything)
You can have WinSCP open PuTTY terminal client and execute the commands there.
With some setup you can even open the PuTTY in the same directory as you have opened in WinSCP file panel.
Particularly for long-running commands/scripts, you can create a local custom command that runs the script via Plink:
"C:\Program Files (x86)\PuTTY\plink.exe" -ssh !U#!# "!/!"
Check the Use remote files option. Do not forget to select the Local command.
You can also pass the command to PuTTY to using similar method as used for Opening PuTTY in the same directory.

How to make a shell script run automatically daily?

My operating system is windows xp and my server is Linux. I have developed a code in perl(saved in shell file).
I want to connect to Linux machine from Windows using your script only and then run a script on linux and this should be done on daily basis and automatically also.
Is it possible to do that?
Shell file under windows? that's called a batch file
Here is an example how you can set up a scheduled task on windows
If your remote machine is on linux, you can read here how you can set them.
You have several options to run the script on remote machine:
copy the file on the remote machine in the same location with the same file name (with ftp or ssh you can do this with another script) and set the linux machine's cron job to execute that same file daily
install a (web) server on the linux machine and create a web page through which's interface to upload and execute the script (this way you don't have to set up a cron job on linux)
create a script on the linux machine which to connect to another service (like a ftp location), download the needed script (the one which you want to execute) and execute it. Put the downloading script in your cron to execute whenever you want
use Net::SSH::Perl in your script to run commands on the linux machine (for this, you need ssh access to that machine, obviuosly)
Yes. Create a Scheduled Task which runs the PERL.exe with the script file name as an argument.

Resources