Solved

Batch to create semaphore

Posted on 2013-11-13
2
541 Views
Last Modified: 2013-12-03
After receiving a FILENAME_yyyymmdd .txt file from vendor I need a Unix batch script to accomplish the following:
1.      Copy the original file to the "archive"
2.      Rename original incoming file FILENAME_yyyymmdd .txt to FILENAME.txt
3.      FILENAME.sem - create a semaphore file. Nothing needs to be in here. It is
                 simply a flag to the batch that indicates the file retrieval is complete.
4.              Alert relevant parties via email
The most important pieces of that are created the .sem file and transferring/renaming the FILENAME_yyyymmdd .txt  to FILENAME.txt file.
0
Comment
Question by:lsbrown1
  • 2
2 Comments
 
LVL 37

Accepted Solution

by:
TommySzalapski earned 500 total points
ID: 39648267
#Assuming that $filename is FILENAME_yyyymmdd.txt
cp $filename /path/archive/
#Strip off _ and everything past _
temp=$(echo $filename | sed 's/\(.*\)_.*/\1/')

#move
mv $filename $temp.txt
#create blank file
echo > $temp.sem
0
 
LVL 37

Assisted Solution

by:TommySzalapski
TommySzalapski earned 500 total points
ID: 39648356
Note that the above will only strip the last _ and everything following it, so filename can have _ characters and it will still work. If you want to strip the first _ and everything after, you could use something a lot simpler like:
temp=$(echo $filename | sed 's/_.*//')
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Report events not being triggered 8 113
mapAB Challlenge 35 123
Tviruailstringtree sort multi columns on header click 1 52
Java Loop 6 48
This article will show, step by step, how to integrate R code into a R Sweave document
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now