Results 1 to 8 of 8

Thread: SSH and bash script

  1. #1

    SSH and bash script

    I just have a little question... I have a script in which I would like it to SSH to a server, then perform operations on that server.
    Now, when I simply performed (in the script) 'ssh backups' or 'ssh xxx.xxx.xxx.xxx, it seemed to hang, I suppose because the script was waiting for the SSH session to end before proceeding to the next instruction. Now, I know that I could simply do 'ssh backups <command>', but what if the command requires some sort of human interaction? Say, I wanted to change a password or something... 'ssh backups passwd ron'. How on earth would I do that? I have heard about expect, but have no idea how to use it, or how to incorporate it into my script. By the way, I am writing a script to do various admin tasks on some new systems I am putting together. I'm not changing passwords, but that was the first example to pop into my head that required some interaction... I just figured that many things could be automated (such as adding installation sources, adding groups, etc.) so that I don't need to do each one individually. I can just plug the newly built box into my network, install Linux, then run a script to do some things that I do to all of my machines...
    Asus A8V Deluxe Mobo
    AMD Athlon64 X2 4400 -939
    2GB Crucial DDR3200 Dual-Channel
    ATi AiW 9800 Pro 128DDR
    Audigy2 ZS
    Sony DRU-810 DVD+RW DL
    3 x Maxtor MaxLine SATA 160Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 300Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 120Gb 16Mb Cache

  2. #2
    Advisor Outlaw's Avatar
    Join Date
    May 2001
    Location
    Clifton Park, NY
    Posts
    630
    This link may provide some help.
    http://enterprise.linux.com/article....724216&tid=129

    That, in combination with cfengine may be what you want to look into

  3. #3
    The only problem with imaging is that it isn't quite flexible enough. Let's say I want to script a system update, that way the system is completely up to date, instead of being as up to date as the image. Or, if I want to add users, but the user names aren't the same? I don't know... These examples aren't exactly what I had in mind, but show a level of flexibility I am needing.
    Asus A8V Deluxe Mobo
    AMD Athlon64 X2 4400 -939
    2GB Crucial DDR3200 Dual-Channel
    ATi AiW 9800 Pro 128DDR
    Audigy2 ZS
    Sony DRU-810 DVD+RW DL
    3 x Maxtor MaxLine SATA 160Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 300Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 120Gb 16Mb Cache

  4. #4
    Advisor Outlaw's Avatar
    Join Date
    May 2001
    Location
    Clifton Park, NY
    Posts
    630
    Images are complete copies of a filesystem, and their files can be edited. Images on a server can be updated when a change is made to a client, and only the changes need be copied over to the image. You can also make changes to the image on the server and push it out to clients
    There seems to be quite a bit of flexibility there.


    cfengine:

    http://www.debian-administration.org/articles/223
    it is possible to script and automate many things across the LAN, such as:
    • Checking file permissions and ownerships; fixing them if required.
    • Restarting failed daemons/servers.
    • Installing software remotely, including security updates.
    • Editing files remotely.
    • Executing commands remotely.
    • Configuring network interfaces, routing, and DNS.
    • Compressing, deleting, or otherwise managing files or directories.

  5. #5
    Ah haa... Yeah, that doesn't look to bad. As soon as I saw 'image' I guess my brain didn't read much further. I'll take a close look at that... Thanks!
    Asus A8V Deluxe Mobo
    AMD Athlon64 X2 4400 -939
    2GB Crucial DDR3200 Dual-Channel
    ATi AiW 9800 Pro 128DDR
    Audigy2 ZS
    Sony DRU-810 DVD+RW DL
    3 x Maxtor MaxLine SATA 160Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 300Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 120Gb 16Mb Cache

  6. #6
    In any case, is there a way to run interactive commands through the shell (script), or is that where you would need to resort to something like expect?
    Asus A8V Deluxe Mobo
    AMD Athlon64 X2 4400 -939
    2GB Crucial DDR3200 Dual-Channel
    ATi AiW 9800 Pro 128DDR
    Audigy2 ZS
    Sony DRU-810 DVD+RW DL
    3 x Maxtor MaxLine SATA 160Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 300Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 120Gb 16Mb Cache

  7. #7
    thanks

  8. #8
    My suggestion for running commands on remote servers in general:
    setup the server you want to run commands off of with trusted SSH access to the boxes you want to run commands on:
    http://news.softpedia.com/news/How-t...on-38599.shtml

    This way, you can just script:
    ssh HOST <command1>
    ssh HOST <command2>
    63,000 bugs in the code, 63,000 bugs,
    ya get 1 whacked with a service pack,
    now there&#039;s 63,005 bugs in the code!!

Similar Threads

  1. Help with bash script
    By woodson2 in forum Linux - Software, Applications & Programming
    Replies: 5
    Last Post: 12-30-2010, 07:19 PM
  2. Bash script problem
    By Schotty in forum Programming
    Replies: 1
    Last Post: 04-20-2007, 01:18 AM
  3. Bash script
    By linuxuser in forum Programming
    Replies: 1
    Last Post: 09-01-2005, 03:21 PM
  4. Help with bash script
    By tolstoy in forum Programming
    Replies: 5
    Last Post: 05-21-2002, 11:17 AM
  5. Bash script for sorting mp3's.
    By airhead in forum Programming
    Replies: 7
    Last Post: 02-24-2002, 07:09 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •