Robot Framework - Connecting to new shell and executing commands - robotframework

I am using SSHLibrary to Open Connection and Log In to a machine which doesn't use the standard Linux Shell. After having logged in to that machine, to use the Linux shell I run the command shell and then provide a username and password to connect to it, using SSHLibrary's Write.
So far so good, but then how can I continue writing to the shell I just opened? Continuing to use Write Commands to execute something like ls doesn't seem to work.
The Keyword Connect to SDWAN Shell is the one I used to connect to the new shell. The new shell opens by Writing the credentials but the next Write which is the ls command doesn't seem to work.

Related

How to access R session/global environment after running script through Rscript on Linux

I am using a Linux Workstation to run my R script. I did so using screen and then Rscript myRscript.R. Is there anyway to access the R session after the script has run? I want to be able to write new commands and access the global environment that was created during that session.
I tried asking the Unix community, but no response...
https://unix.stackexchange.com/questions/608073/how-to-pass-code-to-attached-screen
The session is lost after the script is done running. But you can save the environment using save.image("env_file.Rdata") and use it later using load("env_file.Rdata").
See http://ugrad.stat.ubc.ca/R/library/base/html/save.html

Running java based webdriver scripts in unix server

I have written webdriver+TestNG scripts in windows using java. Now there is an upcoming requirement to run the same scripts in UNIX server without much of code modification. I have heard about running tests in headless browser, but I dont know about this much. I searched a lot but there is no clear and simple response to start looking into this.
Is it possible to just change the driver instance to htmlunitdriver and run the same in unix environment? How could I create the tests as a package and move to unix environment for running the scripts?
You can run your existing script by making few changes in driver instance creation. Suppose you are using Firefox driver for your test, then you can run your script in headless mode using virtual display Xvfb (Xvfb is an X server that can run on machines with no display hardware and no physical input devices).
Below are the steps to run your tests in headless mode:
Install Xvfb
Start the Xvfb by executing this command Xvfb :99 -screen 0 1024x768x24 & Xvfb Manual
Then create a Firefox driver instance that uses virtual display started in step 2 as below:
FirefoxBinary fb = new FirefoxBinary();
fb.setEnvironmentProperty("DISPLAY", ":99");
WebDriver driver = new FirefoxDriver(fb,null);
Now your script will run in headless mode. You may need to change few other things like path of your test data or any other references that uses windows file system (like C:\)

Triggering a windows batch script from unix shell script

I Have a unix shell script, after it runs, it will ftp a file to windows server. Then i need to manuallu schedule a windows batch script. couls you please suggest me method where i can call the batch script from the unix shell script.
Thanks in advance
Take a look at this:
https://stackoverflow.com/a/16720186/2471910
It talks specifically about invoking a windows program from another windows machine (instead of a unix machine) but the concepts are the same since ssh is available on unix as well.

Pipe a file on a Unix server to the client

I'm using PuTTY to connect to a zOS mainframe (running USS, IBM's Unix-compatible software) and I'd like to download a hex dump (using od) of a file without making a copy of it on the filesystem. Is there a way that I can save or pipe stdout (through PuTTY) directly to a file on my (Windows XP) client?
You could configure session logging for your PuTTY session, as per the documentation. Then just run od on the server, wait until it finishes, and then close your log file. You'll need to trim the cruft at the beginning and end (because it has your whole session), but you should end up with what you want.
Note that upon inspection that documentation link may be for an older version of PuTTY, so YMMV but I'm sure that more recent versions also support session logging.
If you were to install a command-line ssh tool (e.g., running OpenSSH under Cygwin), you could then do the standard "ssh hostname command > file" sort of redirection.

shell script running by sensing a file

i am working on unix.
i want to write a shell script which will check for a file called "temp_file.txt" on windows
and then execute some commands.
is this possible?
how could we connect to the windows and go to a specific directory and check for a file?
Share the directory on the Windows machine using the "regular" Windows file sharing facilities. On the Linux side, you have two options:
Use smbclient to connect to the Windows machine and check if the file exists or
Use smbmount to mount the shared directory into your Linux file system and check file existence using "standard" Linux commands (e.g. test).
The exact implementation details will depend on the scripting language that you use, but your pseudo-code will look something like this:
loop:
check if file exists
if yes: do something useful
sleep for some reasonable time
(I am assuming that you want to execute the commands on the Linux machine.)
If you're using Linux (you specify that you're using Unix, but not what variant), check out the inotify API --- this will allow you to set up event responders for filesystem events (much more efficient than polling).
From a shell script, you can use the inofitywait command --- see http://linux.die.net/man/1/inotifywait for more information.
you could set up SSH on Windows and then write a script on Unix using the SSH client to connect to Windows and execute the command. The alternative, if you can afford to, it to write a windows batch, and execute your command on Windows itself. Or you can turn on Windows terminal services, and use telnet protocol from Unix to issue the command. Programming languages that support telnet includes Perl (Net::Telnet) and Python(telnetlib)
As ghostdog74 suggested, ssh is your best bet. You can run something like (I assume you have Cygwin or SFU installed)
ssh "[ -e $file ] && do_something.sh" > do_something.log
If your command logs to stdout, you get the log on your Linux box as well.
If you set up private key authentication, it gets even better.

Resources