Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 17
Hi Guys, I want to do the following in an Automatic Command or Command Script. I want my Ubuntu Server to download a file form a web server and extract ...
  1. #1
    Just Joined!
    Join Date
    Nov 2011
    Location
    Poole, Dorset, United Kingdom
    Posts
    4

    Run Multiple Commands Automatically

    Hi Guys,

    I want to do the following in an Automatic Command or Command Script.

    I want my Ubuntu Server to download a file form a web server and extract the contents to a location, edit a/some file, and then copy it to another location and then restart a service.

    Is there a simple way to do this or can someone help me write a small program that will do this.

    Regards

  2. #2
    Linux Enthusiast Mudgen's Avatar
    Join Date
    Feb 2007
    Location
    Virginia
    Posts
    623
    That sure sounds like a homework problem. We don't do those here.

  3. #3
    Trusted Penguin jayd512's Avatar
    Join Date
    Feb 2008
    Location
    Kentucky
    Posts
    4,071
    Yes it does...
    Just to point out a reference tool, though...
    Bash scripting Tutorial
    Jay

    New users, read this first.
    New Member FAQ
    Registered Linux User #463940
    I do not respond to Private Messages asking for Linux help. Please, keep it on the public boards.

  4. #4
    Linux Enthusiast Mudgen's Avatar
    Join Date
    Feb 2007
    Location
    Virginia
    Posts
    623
    Also see
    man crontab

  5. #5
    Just Joined!
    Join Date
    Feb 2008
    Location
    Mauritius
    Posts
    8

    script in bash to do your job

    hi mate I mate be able to help but i need more from you about the edditing part what you need to find in the file

    and what you need to edit


    give more info

    i would like to work on the script for you well i will do it in bash

    any way get back to me when you like to get it done
    thanks bye

  6. #6
    Just Joined!
    Join Date
    Mar 2011
    Posts
    7
    I agree with other posters. Seems you want someone to write this for you... But what would you learn then? It sounds like the things you need to research are wget, tar, and service [name] restart commands. Get a start on the script and post it, and i'm sure people would be more willing to help correct issues.

  7. #7
    Just Joined!
    Join Date
    Nov 2011
    Location
    Poole, Dorset, United Kingdom
    Posts
    4
    Hi Guys,

    I am not a student and this is not a piece of homework. I am a network Technician in a School (Ashdown Technology College) and we have just started using Linux (ubuntu) to run a Squid Server. I have an understanding of wget and I know how to extract tar.giz files at the command line. I also know how to restart the Server again from the command line. I'm not an expert in Linux by a long shoot but we wanted something to host a Filtering System.

    I have no idea how to or where to start writing a script to do these things.

    In answer to another question, the files that needed editing need to some data removed and a '.' added at the start of each line in the file.

    I will be looking at the links that have been provided and would be greatfull for any help or input, a starting point would be useful.

    Again I'm not a student I have a Degree in Network Systems Management but have never worked with Linux untill recently when I was instructed to setup the Squid Proxy system.

    Regards

  8. #8
    Linux Enthusiast Mudgen's Avatar
    Join Date
    Feb 2007
    Location
    Virginia
    Posts
    623
    Without that context, it really did look like a generic homework case. We get that all the time, and it's against the rules and not in the best interests of the student.

    If you'll give a bit more context, I think some of the bash/awk/sed wizards around here will walk you through it. Things that will help them:
    --Locations/names of files
    --Samples of data from the files, showing what needs to be transformed--the . at the beginning of each line is cake, but we need to know about the stuff that needs to come out
    --Samples of the commands that you already know how to do from the command line to accomplish pieces of what you need

    Good luck. You've come to the right place, and you responded appropriately to the initial brush-off.

  9. #9
    Just Joined!
    Join Date
    Sep 2011
    Posts
    14
    +1 but more specifically -
    Use sed to remove strings (man sed)
    To add the period at the beginning of each line is going to be slightly trickier, but doable. The technique I'd use is to turn all the whitespaces into a particular string first and then use a pipe with echo and sed. Something like this:
    Code:
    for LINE in $(sed 's/ /BLANK_SPACE/g' file)
    do echo ".${LINE} | sed 's/BLANK_SPACE/ /g'" > file.new
    mv file.new newfile_location
    There are other tactics and probably a lot better ways to get it done, but that might get you started. You can add in another pipe on the second line to filter out a string if you need to, or as many substitutions or deletions as needed can be added to the pipeline.

  10. #10
    Linux Enthusiast Mudgen's Avatar
    Join Date
    Feb 2007
    Location
    Virginia
    Posts
    623
    That's syntactically broken, and conceptually a bit convoluted.
    Code:
    sed -i"" -e "s/^/\./" file
    will put a . at the beginning of each line in file.

    Post up some samples as noted and we'll help you with the script.

Page 1 of 2 1 2 LastLast

Posting Permissions

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