Sponsored Content
Top Forums Shell Programming and Scripting Copy contents of whatever's loaded into the CD drive Post 302571950 by ws6transam on Tuesday 8th of November 2011 04:26:19 PM
Old 11-08-2011
I am using OpenSUSE, latest version.
If I can do this without knowing the CD name, all the better. I just haven't figured it out yet. Somehow I need to seek the disk and find out the folder name without explicitly asking the user to "look" at the directory.

In addition, I have this sample script ALMOST running, but it blows up on the "mv" command, with an error that has me baffled. Also, since the station name is already part of the CD name, I might be able to parse that out and not force the user to enter it twice.

Help is appreciated.


--
Code:
msugws@dynamic-mackeyke-msu:~> ksh copyCD
Ensure that the CD is first loaded within the CD drive and is mounted.
Enter the CD name: (SSSSYYNDD) where SSSS = station name, YY = year, DD = Disc ID:  NMA207N08
Enter the loaded CD identification: 
Мой диск
Your disc name is NMA207N08
Enter the name of the Station. NMA2
Station directory already exists.
Begin copy of contents of Мой диск into directory ~/Documents/Sample_data/NMA2/NMA207N08/
mv: target `/home/msugws/Documents/Sample_data/NMA2/NMA207N08' is not a directory
msugws@dynamic-mackeyke-msu:~>

----
Ksh script:

Code:
USEAGE="usage: copyCD - Copies seismic CDs for the NERSP program"    #
print -n "Ensure that the CD is first loaded within the CD drive and is mounted.\n"
print -n "Enter the CD name: (SSSSYYNDD) where SSSS = station name, YY = year, DD = Disc ID:  "
read diskid
print -n "Enter the loaded CD identification: \n"
read cdname
print -n "Your disc name is "$diskid"\n"
print -n "Enter the name of the Station. "
read stationid
if [[ ! -d ~/Documents/Sample_data/$stationid ]]
then 
    mkdir ~/Documents/Sample_data/$stationid
    print -n "~/Documents/Sample_data/"$stationid" created.\n"
else
    print -n "Station directory already exists.\n"
fi
print -n "Begin copy of contents of "$cdname" into directory ~/Documents/Sample_data/"$stationid"/"$diskid"/\n"
cp -rn "/media/$cdname" "/home/msugws/Documents/Sample_data/$stationid/"
chmod -R 775 "/home/msugws/Documents/Sample_data/$stationid/$cdname"
mv /home/msugws/Documents/Sample_data/$stationid/$cdname /home/msugws/Documents/Sample_data/$stationid/$diskid

--

Last edited by pludi; 11-09-2011 at 04:29 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX Desktop Questions & Answers

How to a see the contents of my CD drive

in a Scoopen server station. In a windows based system you just go to mycomputer- and than double click the cd rom drive icon...simple....But i need to see the same but for a SCO open server....i want the same for a floppy drive tooo... By the way, i tried (scoadmin ) command but couldnt go... (1 Reply)
Discussion started by: BAM
1 Replies

2. UNIX for Dummies Questions & Answers

How to a see the contents of my CD drive

How to a see the contents of my CD drive in a Scoopen server station. In a windows based system you just go to mycomputer- and than double click the cd rom drive icon...simple....But i need to see the same but for a SCO open server....i want the same for a floppy drive tooo... By the way, i... (4 Replies)
Discussion started by: BAM
4 Replies

3. UNIX for Dummies Questions & Answers

copy folder contents

I need to make a new dir in side the dir lab5 the new dir is called testLab5 without changing directories copy all files from your lab5 directory into your testLab5 directory then i have to without chaning directories and using exactly one command remove all files that start with the... (1 Reply)
Discussion started by: robsk8_99
1 Replies

4. Shell Programming and Scripting

copy contents of one column in another

Hi, I want to pick contents of a column in a file and copy the contents of this to other column. awk can be used for this, but the number of fields are higher so awk will not help. Any other way to do this. e.g following file has some contents a follows a,b,c,d,e,f,9,0 i need... (4 Replies)
Discussion started by: raman1605
4 Replies

5. Windows & DOS: Issues & Discussions

List Contents of Drive by size

I am having difficulty listing the contents of a specific disk drive including hidden files and folders by size on disk. Its been a while since i have used dos and batch files in windows as am used to UNIX so was wondering if anybody could help me with this? Regards, Alan Jackson (1 Reply)
Discussion started by: pure_jax
1 Replies

6. Shell Programming and Scripting

copy the contents between two keywords to a new file.

Hi All, I want to edit my gate level netlists by searching for the content between two patterns eg: ff1 \test/a0 ( .CLK(\test/ClkInt0_acb_00x1 ),.D(\test/Rakicc ), .QB(\test/X ), .VDD(1'b1), .VSS(1'b0)); ff1 \test/a1 ( .CLK(\test/medis0_acb_00x1 ),.D(\test/hedwc ), .QB(\test/X ),... (6 Replies)
Discussion started by: naveen@
6 Replies

7. UNIX for Dummies Questions & Answers

Real time status of tape drive loaded for backup

Do we have a way in solaris to actuallyu check in real time the activity of a tape when it is loaded for backup? I know mt -f /dev/rmt/0n stat will provide the status. If it's busy, meaning it's currrently on backup mode or someone is using it (fuser -u /dev/rmt/0n) I wanted to check if the... (3 Replies)
Discussion started by: lhareigh890
3 Replies

8. Shell Programming and Scripting

Need help to copy contents of a file

Hi, I am stuck up with a problem of copying the contents of a directory where one of the folder name is changed daily. Problem: I have the folder structure as: RefWorlds2/LINGCC4_X64/odsdev/odessy/UTI/621GA_build_xxx/.../.. In the above path the build number (xxx) will be changed... (3 Replies)
Discussion started by: SathaKarni
3 Replies

9. Shell Programming and Scripting

Copy contents of one file to another

I need to write a script (in bash) that copies the content of the first file in each folder of a directory to the second file in the same folder. I tried this and it didn't work - it just came back with errors and I'm not sure how to fix it. Help is very much appreciated! for mpdir in... (4 Replies)
Discussion started by: LeftoverStew
4 Replies

10. Shell Programming and Scripting

Unable to copy contents

I am trying to move content of a folder usingls /backup/db_backups/INCREMENTAL/|while read file ; do mv $file /backup_LOCAL/db_backups/INCREMENTAL/ done...but when I run this command using a bash script I'm getting this error ./test.sh mv: cannot stat... (6 Replies)
Discussion started by: rocking77
6 Replies
Net::LDAP::DSML(3pm)					User Contributed Perl Documentation				      Net::LDAP::DSML(3pm)

NAME
NET::LDAP::DSML -- A DSML Writer for Net::LDAP SYNOPSIS
For a directory entry; use Net::LDAP; use Net::LDAP::DSML; use IO::File; my $server = "localhost"; my $file = "testdsml.xml"; my $ldap = Net::LDAP->new($server); $ldap->bind(); # # For file i/o # my $file = "testdsml.xml"; my $io = IO::File->new($file,"w") or die ("failed to open $file as filehandle.$! "); my $dsml = Net::LDAP::DSML->new(output => $io, pretty_print => 1 ) or die ("DSML object creation problem using an output file. "); # OR # # For file i/o # open (IO,">$file") or die("failed to open $file.$!"); my $dsml = Net::LDAP::DSML->new(output => *IO, pretty_print => 1) or die ("DSML object creation problem using an output file. "); # OR # # For array usage. # Pass a reference to an array. # my @data = (); $dsml = Net::LDAP::DSML->new(output => @data, pretty_print => 1) or die ("DSML object cration problem using an output array. "); my $mesg = $ldap->search( base => 'o=airius.com', scope => 'sub', filter => 'ou=accounting', callback => sub { my ($mesg,$entry) =@_; $dsml->write_entry($entry) if (ref $entry eq 'Net::LDAP::Entry'); } ); die ("search failed with ",$mesg->code()," ") if $mesg->code(); For directory schema; A file or array can be used for output, in the following example only an array will be used. my $schema = $ldap->schema(); my @data = (); my $dsml = Net::LDAP::DSML->new(output => @data, pretty_print => 1 ) or die ("DSML object creation problem using an output array. "); $dsml->write_schema($schema); print "Finished printing DSML "; DESCRIPTION
Directory Service Markup Language (DSML) is the XML standard for representing directory service information in XML. At the moment this module only writes DSML entry and schema entities. Reading DSML entities is a future project. Eventually this module will be a full level 2 consumer and producer enabling you to give you full DSML conformance. Currently this module has the ability to be a level 2 producer. The user must understand the his/her directory server will determine the consumer and producer level they can achieve. To determine conformance, it is useful to divide DSML documents into four types: 1.Documents containing no directory schema nor any references to an external schema. 2.Documents containing no directory schema but containing at least one reference to an external schema. 3.Documents containing only a directory schema. 4.Documents containing both a directory schema and entries. A producer of DSML must be able to produce documents of type 1. A producer of DSML may, in addition, be able to produce documents of types 2 thru 4. A producer that can produce documents of type 1 is said to be a level 1 producer. A producer than can produce documents of all four types is said to be a level 2 producer. CALLBACKS
The module uses callbacks to improve performance (at least the appearance of improving performance ;) and to reduce the amount of memory required to parse large DSML files. Every time a single entry or schema is processed we pass the Net::LDAP object (either an Entry or Schema object) to the callback routine. CONSTRUCTOR
new () Creates a new Net::LDAP::DSML object. There are 2 options to this method. "output" is a reference to either a file handle that has already been opened or to an array. "pretty_print" is an option to print a new line at the end of each element sequence. It makes the reading of the XML output easier for a human. Example my $dsml = Net::LDAP::DSML->new(); Prints xml data to standard out. my $dsml = Net::LDAP::DSML->new(output => @array); my $dsml = Net::LDAP::DSML->new(output => *FILE); Prints xml data to a file or array. my $dsml = Net::LDAP::DSML->new(output => @array, pretty_print => 1); my $dsml = Net::LDAP::DSML->new(output => *FILE, pretty_print => 1); Prints xml data to a file or array in pretty print style. METHODS
start_dsml () Start a DSML file. end_dsml () End a DSML file. write_entry ( ENTRY ) Entry is a Net::LDAP::Entry object. The write method will parse the LDAP data in the Entry object and put it into DSML XML format. Example my $entry = $mesg->entry(); $dsml->write_entry($entry); write_schema ( SCHEMA ) Schema is a Net::LDAP::Schema object. The write_schema method will parse the LDAP data in the Schema object and put it into DSML XML format. Example my $schema = $ldap->schema(); $dsml->write_schema($schema); AUTHOR
Graham Barr gbarr@pobox.com SEE ALSO
Net::LDAP, XML::SAX::Base COPYRIGHT
Copyright (c) 2002-2006 Graham Barr. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-01-29 Net::LDAP::DSML(3pm)
All times are GMT -4. The time now is 12:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy