Sponsored Content
Full Discussion: A simple Backup script
Homework and Emergencies Homework & Coursework Questions A simple Backup script Post 302607656 by Waffles on Thursday 15th of March 2012 04:25:06 AM
Old 03-15-2012
A simple Backup script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:
All I have to do is write a script that will take two arguments. The first argument is a list which will contain filenames. The second argument is a directory. Basically the idea is that this script will backup all the filenames that are listed in the file from the first argument.
I talked to my proffessor and looked at my book. Both have stated that A foreach loop is the best way to go about handling this assignment.

So far I can see that the foreach loop is only able to take in one argument. This works fine but I need to add another argument for the user to write so that the data is sent to the directory. Can I give a foreach loop more than one argument???



2. Relevant commands, code, scripts, algorithms:
#!/bin/csh

foreach filename (`cat $argv[1])
echo $filename
cat $filename
end

All this does is it takes a list of files, prints out the names of those files and then the content of each file.

3. The attempts at a solution (include all code and scripts):
I tried using the set $argv[1] = $< and set $argv[2] = $< to have the user give the arguments right away. But it didnt work. The subscript ws out of range.


4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):



Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

University of Colorado at Colordo Springs
The Course is: CS209 Programming with Unix
The Proffessor is Pam Carter.

---------- Post updated at 02:21 AM ---------- Previous update was at 02:14 AM ----------

I forgot to mention that all I really need to do once I extract all the files from the filelist is use the mv or the cp command to copy or move them to the directory. It's really not that hard.

---------- Post updated at 04:25 AM ---------- Previous update was at 03:21 AM ----------

Nevermind. I figured it out.

heres the finished code:


#!/bin/csh
foreach filename (`cat $argv[1]`)
cp $filename $argv[2]
end


I didn't realize that $argv[2] can be placed anywhere in the script while still referring to the second argument. Its that whole idea of positional parameters. I was so used to coding with java and other programming languages that use order and where the placement of variables/parameters actually mattered. It took me about 5 hours to figure that out. I am mad and happy at the same time.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Diff. Backup Script Using TAR. Should be simple.

I'm specifically trying to find help or insight on using the --incremental ('-G') option for creating a tar. Please resist the urge to tell me to use --listed-incremental ('-g') option. That's fairly well documented in the GNU tar manual. GNU tar 1.19 This is what the manual does say in section... (0 Replies)
Discussion started by: protienplant
0 Replies

2. Shell Programming and Scripting

[bash] Simple backup (cp) script but incremental

Hi all, I would need a rather simple bash backup script that loops throught the (local) users and for each users backs up (cp!) its /home/username folder. About the functionalities: The script has to run every 2 hours (that's cron, so don't mind about that) and the files should be copied to... (12 Replies)
Discussion started by: laurens
12 Replies

3. Shell Programming and Scripting

How to create a simple shell script to backup

Hello - I am in process of deleting many files which are older than 4 weeks. For example I am inside: /subsystem/prod/ Files are with various extentions, but anything older than 4 weeks should be deleted. What would be the most simplest script to acheive this? (4 Replies)
Discussion started by: DallasT
4 Replies

4. Shell Programming and Scripting

rsync backup mode(--backup) Are there any options to remove backup folders on successful deployment?

Hi Everyone, we are running rsync with --backup mode, Are there any rsync options to remove backup folders on successful deployment? Thanks in adv. (0 Replies)
Discussion started by: MVEERA
0 Replies

5. Shell Programming and Scripting

Help making simple perl or bash script to create a simple matrix

Hello all! This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician. Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix: ... (16 Replies)
Discussion started by: torchij
16 Replies

6. Shell Programming and Scripting

Help with Backup Shell Script for Network Device Configuration backup

HI all, im new to shell scripting. need your guidence for my script. i wrote one script and is attached here Im explaining the requirement of script. AIM: Shell script to run automatically as per scheduled and backup few network devices configurations. Script will contain a set of commands... (4 Replies)
Discussion started by: saichand1985
4 Replies

7. Homework & Coursework Questions

Create a simple bash backup script of a file

This is the problem: Write a script that will make a backup of a file giving it a ‘.bak’ extension & verify that it works. I have tried a number of different scripts that haven't worked and I haven't seen anything really concise and to the point via google. For brevity's sake this is one of the... (4 Replies)
Discussion started by: demet8
4 Replies

8. Shell Programming and Scripting

Shell script to call Oracle archive backup script when file system reaches threshold value

Hello All, I need immediate help in creating shell script to call archivebkup.ksh script when archive file system capacity reaches threshold value or 60% Need to identify the unique file system that reaches threshold value. ex: capacity ... (4 Replies)
Discussion started by: sasikanthdba
4 Replies

9. Shell Programming and Scripting

Simple .sh and alias or ? whatever. Do backup!

Hi , Using bash shell (mintty) in cygwin/windows env. for some time and having issues with most basic commands. Will be quite easy to get er done once I know how , just like magic tricks. I need either alias OR shell script to change windows to posix path AND put that line back -input OR .cd to... (2 Replies)
Discussion started by: sircuts
2 Replies
lmfsetup(8)						      System Manager's Manual						       lmfsetup(8)

Name
       lmfsetup - License Management Facility PAK registration script

Syntax
       /etc/lmfsetup [ template ]

Description
       The  script allows you to register data supplied by a Product Authorization Key (PAK).  The script prompts you for the data associated with
       each of the fields on a PAK.  When all the data has been entered, the License Management Facility (LMF) ensures there are  entries  against
       all  the mandatory fields, and that the Checksum validates all the license data.  If the data has been entered correctly, the PAK is regis-
       tered in the License Database.  If the data has been entered incorrectly, the appropriate error message is displayed and you are given  the
       opportunity to re-enter the data.

       The template option allows you to register license data from templates in A template containing a partially complete PAK is created by some
       products as part of their installation process.	The script only prompts you for data on the fields that are empty in the template.  If the
       script cannot find the specified template in it searches the current directory.

       The  script  is	provided as an alternative to the command.  This displays a template, which includes the fields on the PAK, and invokes an
       editor so that you can add the license data to the appropriate field.  The command also allows errors to be corrected without having to re-
       enter all the data.

See Also
       lmf(8)
       Guide to Software Licensing

																       lmfsetup(8)
All times are GMT -4. The time now is 02:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy