Help required for Running SQLPLUS command from Bat file
GeneralThis forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
@PavanPatil: You've posted your Windows related question on a Linux forum. That's not such a big problem (enough people here know something about Windows). I did ask a moderator to move this thread to the General section, this not being Linux related and all.
Forget what I first wrote, I got the "putty" syntax wrong.
The "2.txt" file should contain commands as you would type them on the Linux system. Does the command
Code:
sqlplus u/u@host @/root/home/sql1.sql
in fact do what you want it to do?
Also, does the user account you specify with the "-ssh" switch have read access to the /home directory? (And why did you place the .sql file there in the first place? Wouldn't the home directory of the user you're connecting as be a better choice?)
Yes, command which I placed in the sql are proper. If I run this SQLPLUS command by directly login into PUTTY then, it works properly. Only the problem is if invoke the Putty from Bat file, then this SQLPLUS command wont work at all.
Sorry for posting path wrongly in my first post, I apologize for the same. The file is present in the Logged in USER folder only and user has all the necessary access to the folders.
Yes, command which I placed in the sql are proper. If I run this SQLPLUS command by directly login into PUTTY then, it works properly. Only the problem is if invoke the Putty from Bat file, then this SQLPLUS command wont work at all.
When you say it "won't work", exactly what happens?
Does a "putty" window appear? If not, then perhaps the batch file can't find the putty.exe program file, and you need to specify the full path.
If a window does appear, does it connect? Do you get an error message?
If the window opens and closes too fast for you to see any messages, have you tried putting the command "pause" at the bottom of the batch file?
Have you tried removing "start", so the batch window remains until the putty.exe process exits?
The only error I can find, is in the "2.txt" file. There should be a "logout" command on the line below the sqlplus command, otherwise the ssh session will remain open. But the sqlplus command should still run.
Putty opens and closes fast for me to see any message. I tried with Pause and its not waiting. It won't work means "What i want to achieve is not happening". If I try without sqlplus command like other MKDIR,CHMOD that file is also executing properly. Only file with SQLPLUS is failing to execute (It just runs without any error but not executing any commands). I assume its not working because from Bat file first I am referring 2.txt (by a path) then again I am accessing one more file (by a path).
For the batch file to work, it must be able to locate putty.exe. Unless putty.exe resides in a directory that's in the system search path, or you specify the full path in the batch file, it won't work. That's why I asked where you've saved putty.exe.
There is one other possibility... Does SQL+ require a terminal to be attached? If it does, then directing putty to use a terminal even for commands that don't (such as running a command directly) might fix the problem.
This also occurs system-to-system with usage like "ssh user@host <commnds" because ssh will not use a terminal either.
I have placed putty in proper place only. Putty screen appears for me. I have one more similar situation where in one file I have only unix commands which running properly. Only this SQLPLUS is not happening.
I have one more similar situation where in one file I have only unix commands which running properly. Only this SQLPLUS is not happening.
And this other fil that runs Unix commands is similar, with the command(s) stored in a text file on the C: drive?
You said the batch file didn't stop even when you added a "pause" command. I'm sorry, but that just isn't possible, not if you edited the right file and added the "pause" command on a line by itself. "pause" always waits for [Enter] to be pressed.
The "start" command means putty gets opened in a separate window.
I've just tried using putty to run commands on a Linux system in exactly the same way (specifying a user/hostname and password with the -ssh and -pw parameters and putting shell commands in a text file referenced by the -m parameter), and it worked just fine.
What do you mean by "putty rights information"?
Can the Windows computer resolve the computer name "host" (I realize that's not the actual name), or are you using an IP address in the "-ssh user@host" parameter?
If you leave out the "-m" parameter entirely, Putty should connect and log in, and give you a command prompt. Does that work?
Definitely try that... When I gave a quick test to see what happens with a "echo tty | ssh -t localhost" I got logged in, but the server still didn't start a pseudoterminal (the output was "not a tty"). Now this COULD be a trait of ssh when stdin is not a terminal.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.