plink unable to execute the command with parameters - plink

i could not able to execute the command with parameters in the plink.exe, when i provide the parameter command 'ls', it executes perfectly.
but if i provide command with parameters let's say 'ls -ltr', it say's commmand not found, this command executes perfectly in the unix command shell.
source code
c:\Gopal\putty>PLINK.exe -ssh gopc#hyperlvs03.qa.paypal.com -i c:\gopal\putty\gopc-private-key.ppk 'ls'
5036
BR-SWAT
CustomerOnBoardingEmailDataVO.oml~
GOPC.PG.conf
GOPC.PG.log
GOPC2.PG.conf
GOPC2.PG.log
GOPC2_PG.py
GOPC2_PG.pyc
GOPC_PG.py
GOPC_PG.pyc
GTest
Mail
\
afiedt.buf
color.sh
color.txt
compile.ksh
compile.ksh.bkup
error_log
file_backup_script.ksh
file_comp.txt
file_comp.txt_dev_BR_SWAT_38350
file_comp.txt_webdev_BR_SWAT_38350
file_not_found.txt
files_diff.txt
files_diff_compare.sh
gimp
gopc-0af4ba41-7528-20110810-211015190-cc_confirm.confirm_cc.vo.req.xml
i686
logs
mm-logs
mycommit
oradiag_UNKNOWN
oradiag_gopc
projects
public_html
scratch
scripts
stage.txt
tr
web.log
c:\Gopal\putty>PLINK.exe -ssh gopc#hyperlvs03.qa.paypal.com -i c:\gopal\putty\gopc-private-key.ppk 'ls -ltr'
bash: ls -ltr: command not found
please find the screen shot for the reference.

Related

Run .sql file from batch file

I'm new to batch files and would like to execute sql script from the batch file. Please can someone assist.Thanks in advance.
You can use sqlcmd.exe from the DOS prompt. If you run sqlcmd -? from the DOS prompt the program will tell you the command line parameters. Here's an example
sqlcmd -S MyDbServer -d DatabaseName -E -i "MyScript.sql"
The -E tells sqlcmd to use "trusted authentication" meaning your Windows login. If you're not using Windows Authentication then you'll want to use the -U and -P parameters.

AIX script hangs when using /dev/null > 2>&1

I am trying to run a script in AIX to execute another script on a remote server. In addition to the remote script i need to send the stdout to /dev/null. The same command works fine on another server but when I run on the current server it hangs, any advice?
su - test -c "rsh testserver /scripts/testme" 2>&1 >/dev/null1
In your comment you write that a menu is presented when the user logins.
Let's say this is done in the .profile file, using echoes and a read command.
When a menu is presented, the read command in the menu code will not be skipped by redirecting the output. The menu still waits for your input and the su command seems to hang.
Can you change your .profile or .bashrc so that it will skip presenting the menu when called using a su command? When this is called during startup, you can look at the returncode of tty. When you use the su command from the commandline, you should look for another solution.
When your root shell is ksh, you can try the following:
if [[ "$(ps -fp $$)" != *"-ksh -c "* ]]; then
echo "Now I should call the Menu"
fi

How to save a SQLCMD code as a executable file

I have a set of SQLCMD codes which are to be saved as exe files so that people can just execute the file rather than copy paste the code and run the command in command line.
Write your sql code to file for example script.sql and than create a batch file (for example run.bat) with below command
sqlcmd -U user -P passwrod -S SerwerName -i C:\script.sql

Executing a bash script in Oracle/Sun GridEngine

I have a script which begins by defining a series of variables, before running a programme with those variables. However, the script is being rejected from Grid Engine (it works on a workstation, but as one component of an array job, it needs to run via SGE) because the variables are being read as commands, resulting in a "Command not found" response.
The error is completely reproduced using the following:
#!/bin/bash
#$ -M not.real#email.address
#$ -m be
#$ -o /scratch/MScGWAS/Output
#$ -e /scratch/MScGWAS/Errors
#$ -q long.q
#$ -cwd
CHR=$1
CHUNK_START=`printf "%.0f" $2`
CHUNK_END=`printf "%.0f" $3`
Output Example:
CHR=1: Command not found.
CHUNK_START=1: Command not found.
CHUNK_END=5000000: Command not found.
How can I get GridEngine to use bash as the interpreter for this script?
You are not executing your script with bash, but with a different shell (e.g. tcsh).
It sounds like your grid engine cluster is configured with the queues in posix_compliant mode and /bin/csh as the default shell. In posix_compliant mode the initial #! is ignored and you need to specify the shell via a command line switch or with a suitable #$ directive.
Adding the following line to your script should work:
#$ -S /bin/bash

tail -f using PuTTY hangs

I am using PuTTY command line to connect to a server and tail a log file. On local machine I've created a file "tail-exec" which contains following text:
tail -f /var/log/test.log
I am starting putty through command line as:
putty -ssh -t -pw -m tail-exec user#server
This opens up the terminal window with log tail. But the problem is that this terminal hangs after there are few hundred lines added to the log.
If I open putty manually, and then run the tail command from the bash prompt, then it is not hanging for thousands of lines also.
I've tried using following text in tail-exec file, but same issue is happening:
bash -i tail -f /var/log/test.log
Any idea what could be the issue?
Try to use a saved session where you set the Option "Keepalive". The use the session like this:
putty -ssh -t -pw -m tail-exec -load 'session-name'