I am trying to execute below unix script to fetch the oracle version from windows command prompt using ssh command to connect to unix terminal
#!/usr/bin/ksh
Freport=/tmp/test.txt
cd /usr/oracle2/product/11.2.0/bin
echo "Begin" > $Freport
set +x
/usr/oracle2/product/11.2.0/bin/sqlplus -V >> $Freport
set -x
pwd >> $Freport
echo "Completed" >> $Freport
Windows command prompt output
Begin
/usr/oracle2/product/11.2.0/bin
Completed
Same script ran in unix server and got below output
Putty output
Begin
SQL*Plus: Release 11.2.0.1.0
/usr/oracle2/product/11.2.0/bin
Completed
I want to print the oracle version in my windows command prompt output. Kindly help me to resolve it
Windows cmd prompt execution
C:\programfiles\PUTTY>putty.exe -ssh uname#ip -pw pwd -m windowsscriptpath/test.sh
Can someone please help me with this? I got struck here.. Is there any option to execute the unix server script directly from windows since shell script is working fine in unix server –
Related
I am trying to run a batch file which is placed in a remote windows server from my local system.
For that I am using psexec command as shown: psexec \\ip address -u user\username -p password cmd /c "path to batch file". This is executing same way as it executes on remote windows server. but at some point we have to press Q on the command prompt to get to next line on the batch file.
this is how it looks:
on Remote system
But I am unable to press Q on my local psexec command prompt, this is how it looks:
on my local system
is there a way to take key inputs for psexec command?
Thanks in advance.
I tried providing -accepteula option and also pipe it with powershell and try running it.
But no luck on that.
I've been using PSQL 14 on my Windows 10 desktop with Git Bash for a while now without issue. Recently I've had to transition to a Windows 8.1 laptop, and I've come across a problem with running the filename parameter for PSQL. When attempting to run a SQL file with the line psql.exe -U <user> -f src/sql/test.sql the terminal hangs until I use Ctrl+C to exit the command. I can run psql -U <user> and then copy & paste the SQL file text into the terminal to get the results I want, but I don't get why this issue is happening in the first place.
I've checked my PATH environment variables and I do have both the /bin and /lib paths in there. I have also tested changing -f with the < operator, which didn't change anything. Running PSQL on Windows 8.1 isn't an issue, it's just this particular command.
On RHEL, the below command works:
psql -h hostname -U username -p port_no -d database -f /tmp/myfile.sql &> logfile01.txt
On FreeBSD, this throws error:
"Invalid null command"
Please suggest.
If you use this only on the command line then there is no need to change the shell.
To redirect stdout and stderr to a file in C-Shell synthax simply use ">& filename".
Different story is, if you want to write shell scripts. Bourne Shell and it's clones (like i.e. Bash) are better suited for writing script. See this Unix FAQ "Csh Programming Considered Harmful": http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/
This redirection works in bash
&> logfile01.txt
, but it does not work in csh which is the default shell in FreeBSD.
# set | grep shell
shell /bin/csh
# ls -la &> logfile01.txt
Invalid null command.
Bash is not installed by default. You can install it
pkg install bash
and configure it as the default shell.
I have a strange issue. I am trying to close down a handle using Powershell using this 1 liner:
(&"D:\handle.exe" -p "–c C –p 3348 -y")
I am getting the following response:
No matching handles found.
When I run the exact same command in Command Prompt
handle.exe -c C -p 3348 -y
I get:
Handle closed.
I am running Powershell and Command Prompt as Admin.
edit: Note: I can run the same command inside the Powershell Command Window and get the same expected result as I did from the normal Windows Command Prompt.
You don't need any fancy syntax. PowerShell can run command-line programs just like cmd.exe can. Just type the command you want and press Enter.
handle -c C -p 3348 -y
It is likely you need to run this from an elevated PowerShell window, but that's not different from cmd.exe.
I just freshly installed SQL Server Express 2014 via Chocolatey. The service is currently running.
When I run this inside my CMD or Powershell:
> sqlcmd -e -S .\SQLEXPRESS
1> sp_databases;
2>
I get no output, it just goes to the next prompt line.
However when I use this style, I do get output:
> sqlcmd -e -S .\SQLEXPRESS -Q "sp_databases;"
sp_databases;
DATABASE_NAME DATABASE_SIZE REMARKS
-------------------------------------------------------------------------------------------------------------------------------- ------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
master 7808 NULL
model 5312 NULL
msdb 37632 NULL
tempdb 2560 NULL
What could be the reason for this? I have no special configuration for the CMD or Powershell except some colour changes of the console.
Turns out I just needed to run GO at the end of each command. Silly.