LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 01-26-2007, 08:40 PM   #1
frankie_DJ
Member
 
Registered: Sep 2004
Location: NorCal
Distribution: slackware 10.1 comfy, Solaris10 learning
Posts: 232

Rep: Reputation: 30
Logging in and logging out of a server in a script


Hi everyone,

I would like to be able to:
login to an execution node from a headnode of a cluster
have my job done there
logout back to the head node
scp output file to some storage server
repeat the proces in a loop

The problem is, if I put a 'logout' command in a script, I get an error "not a login shell, use 'exit'". If I use 'exit' then this command is interpreted by the shell as exiting the loop and stopping the execution of the script. Is there a way around this?
Maybe using trap to trap a signal or something? I am out of options
- my bash scripting skills are not very refined.

Thanks.
 
Old 01-26-2007, 11:05 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,005
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Code:
for i in true;
do
  ssh user@node -C "command; command2; ... " >> node.out 2>&1
done
No need to log-in and out, all very tidy.


Cheers,
Tink
 
Old 01-27-2007, 07:00 PM   #3
frankie_DJ
Member
 
Registered: Sep 2004
Location: NorCal
Distribution: slackware 10.1 comfy, Solaris10 learning
Posts: 232

Original Poster
Rep: Reputation: 30
Tinkster,

Thanks for the reply. No disrespect, but your suggestion kinda screwed me over. Putting my commands in the quotations deleted all my data files. Fortunately I backed them up beforehand. I ended up using your suggestion for the quotes (thanks for that), but I put all the stuff from inside the quotes in another script and run it that way. It worked.

I have no idea how did I manage to erase everything, and actually, I'd appreciate if someone could explain to me what went wrong.

This is what happened: I have 20 directories called
anneal_1 to anneal_20. Each one has different number of data files called si.001 to si.0** (stars are some nubers). I needed to pick up an si.0** file (from each anneal_* directory) that has the highest number in its name, and then execute simulation on that file. So this is the beginning of the unsuccesfull script - the part that messed me up:

Code:
for i in `seq 1 20`
do
   rsh node10 "
   cd /to/the/appropriate/directory
   max=anneal_$i/si.001
   for j in anneal_$i/si.0*
   do
        if [ $j > $max ]
        then
                max=$j
        fi
   done
   ... " #rest of the simulation run on the node10
I get the error message
Code:
bash: line 8: [: missing `]'
twenty times. After that, all the files si.0** were empty except for the highest-numbered one, and get this: an empty file with the name " ] " showed up in the directory where script is executed (!?!?). How that happened is a great mistery to me . Some weird redirection was done by the '>' character. Actually, without the quotation marks that I use to submit job to the execution node, it works as it's supposed to.

Last edited by frankie_DJ; 01-27-2007 at 10:41 PM.
 
Old 01-27-2007, 10:50 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,005
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Sorry about your loss of data ... I never said I knew what
you're doing, and that my approach was safe for that.

What is your users default shell on the remote node?


Cheers,
Tink
 
Old 01-28-2007, 12:03 AM   #5
frankie_DJ
Member
 
Registered: Sep 2004
Location: NorCal
Distribution: slackware 10.1 comfy, Solaris10 learning
Posts: 232

Original Poster
Rep: Reputation: 30
it's bash, version 3.00. I don't know if I made it clear, but,
when I regularly log in the exec. node and run this script bit, it works fine.

Last edited by frankie_DJ; 01-28-2007 at 12:30 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
script to allow for logging-in dabash Linux - Newbie 3 12-29-2006 04:15 PM
Logging via bash script kleptophobiac Programming 8 07-22-2004 10:21 AM
Script when Logging in jrpretz Linux - General 1 11-18-2003 10:53 AM
shell script for logging threadhead Linux - General 8 12-27-2002 04:59 PM
using red-carpet without logging out and logging as root. packman Linux - Software 1 12-09-2002 03:55 AM


All times are GMT -5. The time now is 12:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration