Hi,
I created a opentap plugin for sending a command and reading the expected value . Iam trying to connect to my virtual machine (which is running on ubuntu) using ssh and then send command to the machine. so I am able to send some commands like “ifconfig” , “cat log.txt”, “touch log.txt” and getting the expected result .
But I am not able to change directory to where my python scripts are. so cd /…/./…/ is not working. It will send the command but not change the directory.
Is there any way to run python scripts as is in opentap code? why my command to change directory is not working, any idea Anyone??
Hi,
If I understand your correctly, you are sending the cd
command using SSH?
If that is the case, your working directory is only changed in that single SSH call, and it will be reset in the next call. You would need to do something like ssh user@server "bash -c 'cd /…/./…/ ; python ./MyScript.py'"
to set the working directory for that SSH call.
I wouldn’t really recommend using SSH if you just need to communicate with your ubuntu VM. It would probably be easier to just run the test plan on your VM instead.
If you want to integrate your plugin with Python, I suggest taking a look at the Python plugin:
Here is the source code: OpenTAP / Plugins / python · GitLab
And here is the documentation: OpenTAP Python Integration
It supports writing test steps and many other OpenTAP abstractions directly in Python
Hope this helps!
Hi @alexander.larsen ,
Thanks for your reply. I understood the issue now. will try with python plugin.
Thanks!
It seems like you are having trouble changing the current directory in your OpenTap plugin when connecting to a virtual machine via SSH. The issue may be due to the way the SSH connection is established and the commands are executed. It’s possible that the “cd” command is not being interpreted correctly by the remote shell. You could try using an absolute path instead of a relative path when specifying the directory, or using the “cd” command in combination with the “source” command to execute a script in the desired directory. Another option would be to use a tool like “scp” to copy the Python script to the remote machine and then run it directly on the remote machine.