Remote login UNIX box from java passing parameters to the custom script called in the profile


 
Thread Tools Search this Thread
Top Forums Programming Remote login UNIX box from java passing parameters to the custom script called in the profile
# 1  
Old 02-24-2017
Remote login UNIX box from java passing parameters to the custom script called in the profile

Hello Good Day / Guten Tag....

I have to login the server and the user profile contains some scripts which need the inputs to be taken from the keyboard.
So I use the method to conn.authenticateWithKeyboardInteractive(username, new InteractiveCallback() {
public String[] replyToChallenge(String name, String instruction, int numPrompts, String[] prompts, ..............

But I can only provide the password and I expect after the password prompt there are two more prompts but it is not coming ,But I could able to connect, but unable to provide some values to the script called
in the profile (. /apps/prod/ia/bin/.dsdprofile)

Kindly help whether Im following the right method to connect in this scenario.

Jsch api have any advanced method for connecting in this scenario? Or can you help me pointing any other api for this?

Im pasting the snippets I used to connect to the remeore unix server from my java program.

Code:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
boolean authenticated = conn.authenticateWithKeyboardInteractive(username, new InteractiveCallback() { 

public String[] replyToChallenge(String name, String instruction, int numPrompts, String[] prompts, 
boolean[] echo) throws Exception { 
System.out.println(name); 
System.out.println(instruction); 
System.out.println(numPrompts); 
System.out.println("Prompts are: "); 
for (String prompt : prompts) { 
System.out.println(prompt); 
} 
if (numPrompts == 0) 
return new String[0]; 

if ((numPrompts > 0) && (prompts[0].startsWith("Password"))) 
return new String[] { password }; 

if ((numPrompts > 0)) { 
for (String prompt1 : prompts) { 

if (prompt1.contains("Hit return after you have read the message of the day")) 
return new String[] { "\n" }; 

} 

for (String prompt1 : prompts) { 
if (prompt1.contains("ORACLE_SID")) 
return new String[] { "OracleSS" }; 

} 

}    
System.out.println(k);    
System.err.println( 
"Warning/FIX: don't know what to do with keyboard-interactive method with unknown prompts"); 
/*System.err.println("Prompts are: "); 
for (String p : prompts) 
System.err.println(p);*/ 
return new String[0]; 
} 

}); 
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Thank you very much / Danke Schon ..

-Sanal



Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 02-24-2017 at 10:31 AM.. Reason: Added CODE tags.
# 2  
Old 03-16-2017
Question Nice Question

Passing object as parameter to method?
Passing object as parameter to Constructor?
In the above two cases it’s the same thing. You didn’t ask the difference between the parameter and constructor, so not gonna dig into that. Constructor is just a special kind of method that has the same name as that of the class.
Passing objects as parameters simply means you are giving some custom datatype value, any value to the method or constructor, for the code inside this method to use.
You make any custom object. You pass this object to your function, for it’s code to work upon. This, in summary, means Passing object as parameter.
and using object as argument inside invoking method or constructor?
Parameters and arguments are mostly used interchangeably. In most texts, and mostly all concepts, they mean the same thing. The fundamental difference is that parameters are the variables defined in the function definition, arguments are the values being passed to the function definition in function call statement.
The language of this part of your question is kinda confusing, but in essence, I think it means that using the object to invoke a function

Last edited by RudiC; 03-16-2017 at 06:43 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Getopt eval set parameters not happening when the script is called through an application!

Hi, There is an Informatica tool through which unix scripts can be called. Now the requirement in my project is that a parent script calls a child script but this parent script has to be called through the Informatica tool. In Parent script I'm using TEMP=`getopt -o x:y: -l area:,volume:... (1 Reply)
Discussion started by: Panna
1 Replies

2. Shell Programming and Scripting

Notify when the script run(hourly)on my jump-box only when there is a failure on my remote-box

Team, Presently I have a script, which i have set up cron on one of my Jump-boxes,and gives me the output on every hourly basis,fetching the data from the remote machine.Basically it gives me the list of all active users logged and its count once we execute the script.Here the count is... (6 Replies)
Discussion started by: whizkidash
6 Replies

3. Shell Programming and Scripting

Passing variable from called script to the caller script

Hi all, Warm regards! I am in a difficult situation here. I have been trying to create a shell script which calls another shell script inside. Here is a simplified version of the same. Calling Script. #!/bin/ksh # want to run as a different process... (6 Replies)
Discussion started by: LoneRanger
6 Replies

4. Shell Programming and Scripting

Passing the value of variable which is read from command line in called script

Hi, I am calling a Perl script in my shell script. When Perl script is executed it asks for a answer to be entered by user from terminal. How can i pass that value from my shell script ?? I know I can change perl script to default the answer but i dont have access to do that so only option i... (5 Replies)
Discussion started by: varun22486
5 Replies

5. Shell Programming and Scripting

Issues for script that login to a unix box

Hi, I have a script that should login to a different box then the box that i am in and run the commands. I have the script sample below that logins to a unix box and get the files .Looks like ls-lrt command is not running or its wrongly used. #!/bin/bash # Ask the user for build month... (5 Replies)
Discussion started by: learninguser235
5 Replies

6. UNIX for Advanced & Expert Users

Why only partiial shell script got executed when called in Java

I'm trying to call shell scripts from Java for DB operations. Using a very simple test, for some reason, one line of (ALTER TABLE) in the shell simply won't be executed while the exit value from the call is "0" (valid exit). When I run the script directly in Unix, it gets executed perfectly fine!!... (4 Replies)
Discussion started by: zmwang
4 Replies

7. Shell Programming and Scripting

Passing unix variable to oracle parameters

Please help me how to pass some unix vairable to oracle. I have used below , but not displaying passed (inval) value. calling() { sqlplus -s $1/$2@$3 <<EOF begin exec call_sql($4); end; exit EOF } calling user pwd inst value1... (17 Replies)
Discussion started by: Jairaj
17 Replies

8. Linux

How to find remote Linux box login account without login in to that box?

Hi, How to find remote Linux box login account without login in to that box? I don't have login account at my remote Linux box. But I need who are all having login account. How do I findout? Thanks, --Muthu. (3 Replies)
Discussion started by: Muthuselvan
3 Replies

9. Shell Programming and Scripting

passing a variables value from the called script to calling script using ksh

How do i get the value of the variable from the called script(script2) to the calling script(script1) in ksh ? I've given portion of the script here to explain the problem. Portion of Script 1 ============= ----- ----- tmp=`a.ksh p1 p2 p3` if then # error processing fi -----... (10 Replies)
Discussion started by: rajarkumar
10 Replies

10. Shell Programming and Scripting

Passing parameters form unix to Oracle procedure

Hi, I have screen which was desined in PL/SQL Catridges in apps. In that screen some enterable fields these values r the passing parameters to create value sets, functions, menus etc in apps by using front end screens. Now in that screen i have a button. when i click that button it have to... (0 Replies)
Discussion started by: rajasekharamy
0 Replies
Login or Register to Ask a Question