Please bear with me, I'm a beginner but have had some experience and decent knowledge to understand things as I read them and I'm in the process of trying to learn more. I recently inherited a UNIX server which has a bash script which is part of a crontab schedule that needs to be modified (or potentially replaced at this point)
Here's what I understand
Essentially, the bash script takes the data that is being sent to the server and after it is successfully received, runs a Unix2Dos command against it -- which doesn't seem to work due to an older version, as well are removes line fees in certain files. It then takes the data, renames it to have a unix2dos extension, sends it out via FTP to another server. It then archives the original data, and the data that has the Unix2Dos command run against it, by running a gzip command against it and then moves it to a folder with a YYYYMM format (example /folder1/Data/VENDOR/inbound/archive/format/201702)
Here is what they now need
Since the Unix2Dos process is not working, we have opted to use another server for the process but the data is still coming through this server and will always be coming into here. We just now don't want to FTP over to another one, or run the Unix2Dos command or remove any line feeds. However, we want to do the following now through a crontab job:
Takes the original data that is being sent to the server, without renaming it, and after it is successfully received, copy it over to a folder (/folder1/Data/VENDOR/inbound/CompanyArchive/format/Unix2Dos) for an outside FTP job to pick up. Only specific file names can be placed here. It then needs to gzip the data, move it over to a folder with a YYYYMM format (example /folder1/Data/VENDOR/inbound/CompanyArchive/format/201702)
I know it seems simple enough, but I have no idea how to do this based on my very limited knowledge of Unix, bash scripting and anything else. I'll share the script and hope many can try to help me here. Thanks in advance for any help provided
Here is our crontab schedule This is the bash script I'm focusing on MoveFormatFiles.sh
(sorry, had to modify this a bit to remove company names and such.. hopefully someone can help me with what I am trying to accomplish)
Last edited by Scrutinizer; 02-04-2017 at 01:27 PM..
Reason: code tags
To help you we need to know a bit more... like your environment:
What architecture, what OS and version etc...
now:
Why call bash as it is mentioned as shell to be used in your script ? Unix2Dos is standard but not on all UNIX and may not have that name ( unix2dos, ux2dos...) without more clues about your OS hmmm....
I can't see a reason why unix2dos should not work, even an older version. Does it if you run it interactively? Does it work on your data files, or mayhap on highly simplified test files?
For clarity, you might want to simplify your - overcomplicated - script as well, and add some decent error checking and logging.
To help you we need to know a bit more... like your environment:
What architecture, what OS and version etc...
now:
Why call bash as it is mentioned as shell to be used in your script ? Unix2Dos is standard but not on all UNIX and may not have that name ( unix2dos, ux2dos...) without more clues about your OS hmmm....
Quote:
Originally Posted by RudiC
I can't see a reason why unix2dos should not work, even an older version. Does it if you run it interactively? Does it work on your data files, or mayhap on highly simplified test files?
For clarity, you might want to simplify your - overcomplicated - script as well, and add some decent error checking and logging.
Thank you both for responding. As far as I can see, it's Sun Microsystems on SunOS 5.9 running Solaris 2.6
As I mentioned, I inherited this but not necessarily inherited the server. I inherited the functions and processes it does. To give an idea of it's main function, it's responsible for receiving a lot of data company wide through a NDM connection. It's one of those servers that needs to be up almost all the time.
From what I know, the user that is running this script is not able to run it as shell but can run it as bash, if that makes any sense at all (sorry if it doesn't, I am fairly new to understand this)
With that said, I should be more clear. It's not that the unix2dos command doesn't work. It does work. It just doesn't work in every case for how they want it to work. The person who wrote this code, made it overly complicated because the person who requested this type of data was also making things complicated. In some cases, line feeds were being left in there after the unix2dos command was ran, but they needed to be removed. In other cases, the line feeds needed to stay in there in certain spots so trying to figure out what was and wasn't needed was a challenge.
Myself and one other coworker figured out that the unix2dos command on this server was older, and wasn't doing everything it was supposed to but we weren't able to get a newer version on there. However, he had the latest on a server he had which worked 100% the way they wanted it to and essentially now he just wants to pick up the data from our server and run the command from there (we can't move the NDM process over, unfortunately, as much as I'd love to... mainly because it does other company functions that actually DO work on this one)
Hope this makes sense and thank you both for the responses.
Hi all,
I have drill to do and I'll very appreciate your help:
Please create a simple CSV file as follow (3 columns and 4 rows):
A,B,C
A,”B,C”,D
“A,B”,C,D
o A,B,”C,D”
- Please refer to the comma between the quotation marks as a parameter and not as a separator.
- Please provide... (3 Replies)
Hi Guys, I want to create a shell script to run multiple jobs in sequence.
Explaination -
If I were to run each jobs individually I would have gone to folder - "abin"(where my shellscript is place) as follows
cd abin
abin > runappeng.sh abc001
Now, I have list of programs which are like... (8 Replies)
Hi,
I'm very new to bash scripting and Linux in general. I'm running Ubuntu Server 10.04 and trying to write a bash script to launch a program. In doing so, I've come across a couple of things that I obviously don't understand. Here is a short script that exemplifies those things:
... (9 Replies)
Hi,
I am newbie in shell scripting
I have a file name like simple.txt which comes from Mainframe systems onto windows dir every 15 minutes daily. File name is same. Every 15 minutes it updates.
I need to write shell script to check if the file arrived every 15 min or not.
If the new file... (4 Replies)
Could someone please recommend a very good shell scripting book for me. I would be starting a new job that would require a very good understanding of shell scripting. Please help. (3 Replies)
hi all,
i am just getting in to bash scripting, so don't be too harsh...
i've created this little backup script, and it's just awfull... ugly, doesn't work like I want it to, the works. anyways, i was hoping some of you might help me improve it and learn a little in the process.
what i... (13 Replies)
I have written a script that will email a generic user when a device is "offline". I would like to enhance this by having the script lookup a contact's email and automatically add it to the MAIL_LIST. I am trying to lookup and return data based on a field common in two files
File 1 ... (0 Replies)
Seems simple but I am having difficulty with this one: I am trying to write a single command line argument (which will be a path) - the program should print out the owner of the path.
I can not get anything I write to run.
Please help. (5 Replies)
I'm relatively new at this scripting game, just need to learn some basic stuff for data handling.
My current need is to write a script that loops through a textfile of filenames, and for each file removes the first line and re-writes that file to a new name.
In fact I could do with knowing... (1 Reply)
Hi there,
I am a student and currently working on a project. I have a file that contains about 50 filenames. (1.txt, 2.txt, 3.txt ...).
I would like to know how can I store these filenames into a variable using a loop?
I would appreciate if anyone can help me. Thank You.
Regards,
Bib (4 Replies)