Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Made Scripts

Status
Not open for further replies.

Norberto

IS-IT--Management
Jun 13, 2000
46
PT
Hi All.<br>I need to made an script, that script must copy some files existe in /usr/bin for a Floppy Disk.<br><br>In manual I do this:<br>doscp file1 a:file1.csv<br>doscp file2 a:file2.csv<br>doscp file3 a:file3.csv<br>Etc, Etc,... Is that possible to made this by an script...<br>I think is easy for users make only &quot;cpfiles&quot; ( name script ).<br><br>Thank you all.
 
Norberto,<br><br>Try this:<br><br>---------------------- 8&lt; ------------------------<br>#!/bin/ksh<br>for I in file*<br>do <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;doscp $I a:$I.csv<br>done<br>---------------------- 8&lt; ------------------------<br><br>(Copy and paste the part between the scissors into an empty file called cpfiles, and make sure it is executable using 'chmod 755 cpfiles')<br><br>The shell replaces file* with the list 'file1 file2 file3 ...' and the for loop executes the doscp command once for each filename in the list.<br><br>Regards,<br><br>Annihilannic<br>
 
Thank You Annihilannic!<br>Can I exectute That file in some Directory???<br><u>(#!/bin/ksh)</u>&nbsp;&nbsp;What that means? <br><br>Regards
 
Norberto,<br><br>'#!/bin/ksh' means that the script will be run by the Korn shell rather than your default shell (in case the script uses some features that aren't available in the current shell).&nbsp;&nbsp;It has to be on the first line of a script.&nbsp;&nbsp;<br><br>Sometimes you'll also see '#!/bin/sh' (Bourne shell), '#!/bin/csh' (C Shell) or '#!/bin/awk -f' (the awk utility) for example.<br><br>My example above assumes that your current directory is the directory containing the source files.&nbsp;&nbsp;If you need it to be run from elsewhere change the 'for file in file*' line to read 'for file in /whatever/directory/file*'.&nbsp;&nbsp;You could then place the script in a directory that is in the path, for example '/usr/local/bin'.<br><br>Regards,<br><br>Annihilannic.
 
Annihilannic. <br>I Have an error.<br><b>WARNING</b> renaming filename rpentha-1.csv to rpentha-.csv<br><b>WARNING</b> renaming filename rpentha-2.csv to rpentha-.csv<br>Ect,...<br>List all files :<br>rpentha-1; rpentha-3; rpentha-4; rpentha-5; rpentha-6; rpentha-7.<br>Why it rename all files to rpentha-.csv?<br>In the end I only have 1 File copy ---&gt;rpentha-.csv<br>I do everything correct. Do You help me?
 
dos files =8 character name & 3 char extension. rename the files to 8/3 before the copy. <p>Ed Fair<br><a href=mailto: > </a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top