Remote Script command logging question


 
Thread Tools Search this Thread
Operating Systems AIX Remote Script command logging question
# 1  
Old 11-16-2012
Remote Script command logging question

I've noticed that when running a script that connects to a number of our servers (to essentially run batch commands) that the commands aren't logged in the user's .sh_history or .bash_history files. Is there a place where this is logged (assuming the script itself isn't doing the logging and I'm not tee'ing the output anywhere)?

I'm talking specifically about AIX, but I would assume this question applies to all the *nix flavors.


As a tag-along to this post, I often nohup these commands (like sendmail -bi) so the script can run through all the hosts quickly. What can I enter in the script to create one large nohup.out on the machine running the script that's reaching out to all the others?Right now I've got
Code:
for node in `cat /home/root/script/shortlist`
#for node in `cat /usr/local/bin/AIX_server_list`
do
echo $node
ssh $node lssrc -s sendmail
echo "***"
ssh $node cp /etc/aliases /etc/aliases.old
scp -p /etc/aliases $node:/etc/aliases
ssh $node nohup sendmail -bi &
ssh $node lssrc -s sendmail
ssh $node cat /home/root/nohup.out >> ~/script/sendmailbi_log.txt
echo "%%%%%%%%%%%%%%%%%%%%%%%%"
done

but that failed miserably, I'm guessing that's because the nohup was given via an ssh and not in an interactive shell so nothing got logged?

Last edited by kneemoe; 11-16-2012 at 01:48 PM..
# 2  
Old 11-16-2012
In short, no. If you use ssh to connect, you can probably put something in the stored public key on the target (~/.ssh/authorized_keys)

Are you connecting as root or a general user?



Robin
Liverpool/Blackburn
UK
# 3  
Old 11-16-2012
See also useless use of backticks. If the list of hosts grows too large your code will malfunction, but this code never will:

Code:
while read node
do
...
done < hostlist

Note you may want to < /dev/null for ssh, so that it doesn't eat lines from stdin inside the loop.
# 4  
Old 11-16-2012
Thanks for the input. I'm doing this all as root.

As for the second part of my post, I ended up putting most of the script in one file that's now being called by a much shorter script that will tee the output to a log file. Its not elegant, but it does what I need it to as far as the logging goes.
Thanks Corona, looks like I've got some more reading to do Smilie

Much appreciated!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execute ssh command with additional terminal command to any remote user not working script

Hello i am having an issue with bash script and this is the code now=$(cat hosts1.txt | awk '{print $2;}') while read n ;do ssh root@$now 'useradd test1; echo -e "test1\ntest1" | passwd test1 && echo "test1 ALL=(ALL:ALL) ALL" >> /etc/sudoers' When i execute only part with cat, it... (8 Replies)
Discussion started by: tomislav91
8 Replies

2. Shell Programming and Scripting

Check/get the exit status of a remote command executed on remote host through script

Geeks, Could you please help me out in my script and identify the missing piece. I need to check/get the exit status of a remote command executed on remote host through script and send out an email when process/processes is/are not running on any/all server(s). Here's the complete... (5 Replies)
Discussion started by: lovesaikrishna
5 Replies

3. Shell Programming and Scripting

Executing scipts after logging into a remote host using shell script

Hi All, Sorry if it is a duplicate post. I have not got any reference about this anywhere. I looked at the posts described in SSH - Passing Unix login passwords through shell scripts - Linux / UNIX Forum and it helped me till the point to connect to the host and executing the basic commands.... (3 Replies)
Discussion started by: RSC1985
3 Replies

4. SCO

sco remote logging problem

Hello, I am trying to write log from sco box to a remote host. We already have that setting working for linux server using syslog. With this setting(on LINUX) *.* @remote-host for sco I have this *.debug /usr/adm/syslog *.* ... (3 Replies)
Discussion started by: polestar
3 Replies

5. Solaris

Logging remote telnet sessions via script

Hi, My requirement - for security purpose - I want all root logins to my solaris servers are done by a script kept in a separate unix box. This script will telnet into remote solaris server with root user and log every session via log file. Now my purpose is to log every telnet session... (3 Replies)
Discussion started by: rahul_jain250
3 Replies

6. Shell Programming and Scripting

Logging Remote SSH command (cannot log a java output)

Hi all I'm creating a script that runs a few commands on some boxes and everything can be logged EXCEPT the java -version command, there doesn't seem to be any output... Can anyone help explain why this does not work? Do I need to do something extra to append the output from the java... (3 Replies)
Discussion started by: Keepcase
3 Replies

7. Shell Programming and Scripting

Problem with logging into remote host

Hi All, I am using a script for remotely logging into a rhost using telnet and shutdown a server. The script is as follows. IP = 10.24.12.23; export IP UNAME = username ; export UNAME PWD = password; export PWD CRDIR = /etc/rc.d/init.d ; export CRDIR echo "logging into remote... (4 Replies)
Discussion started by: patil_reddy
4 Replies

8. Shell Programming and Scripting

Question about how to execute command on the Sorias from the remote.

Hi, all please help me this time@@! I want to execute the shell on the server from the remote. How can I do that and save the return code in the variable? I want to execute the script on the ten servers at the same time... I'd like to find a fast method to solve it! Thanks in advance! (3 Replies)
Discussion started by: GCTEII
3 Replies

9. Shell Programming and Scripting

logging to remote server

Hi, I want to log-in to a remote server using shell script. The server requires the following while allowing a connection: username password one - letter authorisation. How can i implement this in my script? thanks, abey (6 Replies)
Discussion started by: abey
6 Replies

10. UNIX for Dummies Questions & Answers

Delay when logging in remote

Hello again! When I log in to my computer (Ultra 5 running Solaris 8) from a pc (FTP or Telnet) I have to wait forever (about 30 seconds) before I can log in. Is this some kind of security thing? Can I turn it of? How? Anders (8 Replies)
Discussion started by: alfabetman
8 Replies
Login or Register to Ask a Question