VirtualBox start Script from host - unix

I have a VM started and want to start a script from the host, inside the vm.
My Test Script looks like:
sql /nolog <<!
exit
!
when i start from the host:
VBoxManage --nologo guestcontrol "vmname" run --exe "pathToScript" --username xyz --password xyz
i receive an error: sql command not found. BUT in the VM it works!
Why??

It was because my env variables werent loaded. So you have to load them in your script like:
. .profile #this file contains your env variables
sql /nolog <<!
exit
!

Related

I want to get a file from windows machine to unix machine using sshapss command

whn I try to connect windows server from my unix manually I am able to get the file .
sshpass -p "passwd" sftp username#hosname:path
get filnename unipath
I tired above lines manually and I am able to pull file to my unix path .When tried executing same commands via shell script its throwing below error. Can some one help me .
SSHPASS: Failed to run command: No such file or directory

How to execute shell script with arguments in remote unix server using robot framework from local windows machine

I would appreciate sample test steps to achieve this.
I logged into the server and then cd into the directory where the script resides. Then tried to run the script with Execute Command keyword.
Install and import SSHLibrary, then use below code:
Keyword Name
[Arguments] ${server}=${host_url} ${user}=${USERNAME} ${pass}=${PASSWORD}
Open Connection ${server}
Login ${user} ${pass}
${out} ${err} ${rc}= Execute Command cd ${SH_SCRIPT_PATH};sh ${SH_file_name} return_stdout=True return_stderr=True return_rc=True
Should Be Equal ${rc} ${0}
Should Not Contain ${out} [main]ERROR

Rsync command not working

I am trying to run rsync as follows and running into error sshpass: Failed to run command: No such file or directory .I verified the source /local/mnt/workspace/common/sectool and destination directories/prj/qct/wlan_rome_su_builds are available and accessible?what am I missing?how to fix this?
username#xxx-machine-02:~$ sshpass –p 'password' rsync –progress –avz –e ssh /local/mnt/workspace/common/sectool cnssbldsw#hydwclnxbld4:/prj/qct/wlan_rome_su_builds
sshpass: Failed to run command: No such file or directory
Would that be possible for you to check whether 'rsync' works without 'sshpass'?
Also, check whether the ports used by rsync is enabled. You can find the port info via cat /etc/services | grep rsync
The first thing is to make sure that ssh connection is working smoothly. You can check this via "sudo ssh -vvv cnssbldsw#hydwclnxbld4" (please post the message). In advance, If you are to receive any messages such as "ssh: connect to host hydwclnxbld4 port 22: Connection refused", the issue is with the openssh-server (not being installed or a broken package). Let's see what you get you get for the first command

Issue with running commands from shell script

I'm trying to copy files from a remote windows server to Unix server. I was successfully able to copy files from windows server using command prompt but when I run these commands from a script it's not working as expected.
commands used:
sftp user#remoteserver.com
lcd local_dir
cd remote dir
get file_name
exit
When I run these commands from a script the script is stopping after it connects to the remote server.
Can anybody tell me how to fix this issue.
The commands lcd to exit are sftp commands, so you cannont just write them into a script line by line but have to redirect them as sftps stdin:
# all lines till "EOF" will be redirected to sftp
sftp user#remoteserver.com <<- EOF
lcd local_dir
cd remote dir
get file_name
exit
EOF
# here you are in your shell script again, eg:
SFTPRES=$?

nohup - dont want nohup.out but want log going to a different file on the remote server

I'm running the following command (where variables have valid values for ssh command and $file - is a .sql file).
nohup ssh -qn ${ssh_user}#${dbs} "sqlplus $dbuser/${dbpswd}#${dbname} <<ENDSQL | tee "${sql_run_output_file}".ssh.log
set echo off
set echo on
set timing on
set time on
set serveroutput on size 1000000
#${file}
ENDSQL
"
When I was using the above command without "nohup" before ssh command, after 1 hour or so, my connection from source server (where im running ssh) was getting an error/message "Connection reset...." and hanging my BASH shell script (which contains this ssh command in it). When, I use nohup, i dont see the connection issue.
Here's what I'm trying to get and need your help.
Change the command shown above so that the command will NOT create a nohup.out
(Did I read that I can use > instead of | tee ... and use 2>&1)
I DO NOT want to run the command giving a "&" (background)
I DO want a LOG file for the sqlplus session that's running on the target DB server via ssh command/connection (initiated from source server).
Thanks.
You can still lose the connection when running ssh under nohup, so it's not really a good solution. If possible, I would recommend that you copy the sql file via scp to the target server, then ssh in to the server, open a screen and run the command from there (Or run it under nohup). Is that an option?

Resources