Sponsored Content
Top Forums UNIX for Advanced & Expert Users How to execute multiple unix commands in one session from java Post 302277104 by zaideeabu on Thursday 15th of January 2009 11:59:38 AM
Old 01-15-2009
Would this logic work?

FileReader fr =
new FileReader("grepcommands.txt");
BufferedReader br = new BufferedReader(fr);
String inputscript="";
String allscript = "";
sess= conn.openSession();
while((inputscript=br.readLine())!=null){
allscript.append(inputscript + ";")
}

sess.execCommand(allscript);

sess.close();

Explaination:
Multiple execution can be done in sequence when given with semicolon ";"
cmd1; cmd2; cmd3; cmd4

My assumption is exeCommand executes the commands as shell does...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how do i get my script to execute multiple commands?

New to shell scripting. I can't get my script to execute multiple commands. Here's the code. It's a menu script. #!/bin/ksh clear print "SDE MENU" PS3="SDE MENU, enter choice:" select clean_menu in "tasdedev instance 5151" "orkindev instance 5155" "tasdetst instance 5157" "orkinsys... (1 Reply)
Discussion started by: hvincent
1 Replies

2. Shell Programming and Scripting

Can Xargs execute multiple commands of evry input file

Hello , I am trying to print the footer of evry file in the given directory with xargs command like follows ls -1 | xargs -I {} gzcat {} | tail -1 now problem with this is only last file foooter is getting printed as " | tail -1 " is getting executed for the last file. I know this can... (4 Replies)
Discussion started by: nilesrex
4 Replies

3. Solaris

I am not able to login in gnome session and java session in Sun solaris 9& 10

I am not able to login in gnome session and java session in Sun solaris 9& 10 respectively through xmanager as a nis user, I am able to login in common desktop , but gnome session its not allowing , when I have given login credentials, its coming back to login screen, what shoul I do to allow nis... (0 Replies)
Discussion started by: durgaprasadr13
0 Replies

4. Shell Programming and Scripting

Execute multiple commands in a find

I am checking that a file is older than a reference file that I build with a touch command before processing it. If it is not old enough, I want to sleep for an hour and check again. My problem is if it is old enough to process, I want to exit when I am done, but I cannot find a way to exit... (2 Replies)
Discussion started by: prismtx
2 Replies

5. UNIX for Dummies Questions & Answers

cron used to execute multiple commands

have to run multiple commands at a specified time by the user... (3 Replies)
Discussion started by: hemaa
3 Replies

6. Shell Programming and Scripting

Execute commands from script in current bash session

I have a file as follows: cat /etc/mxg/ssh-hostsmx.example1.com.au:2225 mx2.example2.com.au:2225 mx.example3.com.au:2225 mail.example4.com.au:2225 mail.example5.org.au:2225 mail.example6.com.au:2225I want to dynamically create aliases for quick access to these servers from bash. I wrote... (4 Replies)
Discussion started by: jelloir
4 Replies

7. Shell Programming and Scripting

connect to multiple servers using SSH and execute commands

Requirement: Run a shell script with below inputs file name checksum path the script should go to multiple servers (around 35) and verify the input cksum and if there is a mismatch display a simple message to the user that cksum verification failed. host details, user id /... (1 Reply)
Discussion started by: amicableperson
1 Replies

8. Shell Programming and Scripting

How to execute multiple commands in one shot?

for example: I'm greping the process where i can get the location of the file $ ps -ef | grep LLAWP | awk {'print $9'} | tail -1 /Hostname/ihs/INSTANCE2/conf/WebAgent.conf then I need to display second line of WebAgent.conf file: $ cat /Hostname/ihs/INSTANCE1/conf/WebAgent.conf | head... (2 Replies)
Discussion started by: raghur77
2 Replies

9. Shell Programming and Scripting

Using sed to execute multiple commands

Let's say I have a file called test.out. In this file I want to do the following: 1. Search for DIP-10219 and with this: 2. Remove everything in front of cn= 3. Remove everything after *com 4. Remove duplicate lines 5. Replace ( with \( 6. Replace ) with \) For 1-3 I have figured out this... (11 Replies)
Discussion started by: exm
11 Replies

10. Shell Programming and Scripting

Ssh multiple hops to execute commands with arguments

Hi I need to write a script to ssh through several hops (e.g. HostA-HostB-HostC-HostD), where Host A does not have direct assess to HostC ; HostB cannot access HostD directly. when I ssh 3 hops and run command with arg1, arg2 and redirect the output to a file, e.g. HostA> ssh -t HostB ssh -t... (3 Replies)
Discussion started by: chiensh
3 Replies
NE_GET_ERROR(3) 						neon API reference						   NE_GET_ERROR(3)

NAME
ne_get_error, ne_set_error - error handling for HTTP sessions SYNOPSIS
#include <ne_session.h> const char *ne_get_error(ne_sesssion *session); void ne_set_error(ne_sesssion *session, const char *format, ...); DESCRIPTION
The session error string is used to store any human-readable error information associated with any errors which occur whilst using the HTTP session. The ne_get_error function returns the current session error string. This string persists only until it is changed by a subsequent operation on the session. If localisation was enabled at build time, and if necessary enabled at run-time if necessary using ne_i18n_init, the returned string may have been translated into the user's current locale. The ne_set_error function can be used to set a new session error string, using a printf-style format string interface. RETURN VALUE
ne_set_error returns a constant NUL-terminated string. In the default English locale, the returned string will not have a terminating "." period character. EXAMPLES
Retrieve the current error string: ne_session *sess = ne_session_create(...); ... printf("Error was: %s ", ne_get_error(sess)); Set a new error string: ne_session *sess = ne_session_create(...); ... ne_set_error(sess, "Response missing header %s", "somestring"); AUTHOR
Joe Orton <neon@lists.manyfish.co.uk> Author. COPYRIGHT
neon 0.28.4 25 February 2009 NE_GET_ERROR(3)
All times are GMT -4. The time now is 04:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy