Need a Script , we are having Linux box


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need a Script , we are having Linux box
# 1  
Old 09-26-2013
Need a Script to read the contents in the file on Linux box

HI

I need help on developing 2 scripts as mentioned below.

One way process ->

We can get files of 01, 02, 07 record types (Here we need to keep a filter to read the first 2 characters in the file and if they are equal to 01 or 02 we need to do the below process and if its 07 we need to send the file as it is to a folder)

Scenario - 01:
In the file we received it would have only a single line with 300 bytes length, example below,

Code:
01NCX004HTXW000005241 DIEBOLD DECAL       5                                 Y0115131048OPBTicket:7550420   Status:IMPRESORA PROVEEDOR

01 - first field indicates record type
NCX004HTXW - second field
000005241 - third field - so here we want to make this 10 characters data to 30 characters just adding 20 spaces to this third field.

Code:
01NCX004HTXW000005241                     DIEBOLD DECAL       5                                 Y0115131048OPBTicket:7550420   Status:IMPRESORA PROVEEDOR

When we add 20 spaces to the 3rd field the length of record becomes 320 bytes , so we need to trim last 20 characters to make length to 300 bytes.

Response process:

From our backend we may get record types like 11,17,E1,E2,12,13,14 ((Here we need to keep a filter to read the first 2 characters in the file and if they are equal to 11,17,E1,E2 we need to do the below process and if its 12,13,14 we need to send the file as it is to a folder)

Scenario - 11 :

In the file we received it would have only a single line with 600 bytes length, example below, file attached (00567538.001)

Code:
11NCX006QHL7000005241                                                   OPBDIEBOLD DECAL       5             061013101906101310190611131119                                                                       FL0005675338600700338                         OP230

11 - first field indicates record type
NCX006QHL7 - second field
000005241 - third field - so here we want change 30 characters data to 10 characters ( by trimming the data which is coming from position 23 - 43 bytes (total 20 characters))

Code:
11NCX006QHL7000005241                               OPBDIEBOLD DECAL       5             061013101906101310190611131119                                                                       FL0005675338600700338                         OP230

When we trim 20 spaces to the 3rd field the length of record becomes 580 bytes , so we need to add 20 spaces to the end of the file to make length to 600 bytes.
Moderator's Comments:
Mod Comment Please use CODE tags; without them it is impossible to determine the number of spaces between fields and at the end of a line.

Last edited by Don Cragun; 09-26-2013 at 05:29 AM.. Reason: Title has been kept more descriptive
# 2  
Old 09-26-2013
So, what have you tried so far.................?
# 3  
Old 09-26-2013
I will continue to delete any contributions (2 so far) until the user has answered the question asked in post #2. Thanks.
These 2 Users Gave Thanks to Scott For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. How to Post in the The UNIX and Linux Forums

Copying , renaming the file from windox box and ftp to Linux box

Hello my dear friends, Two file are auto generated from mon - fri at different directories on same windows box.Every day i have to copy the file, rename it (specific name)and ftp it to linux box specified directory. is it possible to automate this process,If yes this has to be done from windows... (1 Reply)
Discussion started by: umesh yadav
1 Replies

2. Shell Programming and Scripting

Notify when the script run(hourly)on my jump-box only when there is a failure on my remote-box

Team, Presently I have a script, which i have set up cron on one of my Jump-boxes,and gives me the output on every hourly basis,fetching the data from the remote machine.Basically it gives me the list of all active users logged and its count once we execute the script.Here the count is... (6 Replies)
Discussion started by: whizkidash
6 Replies

3. Linux

Linux script for multiple box login.

Hello! We currently use a SecureCRT .vbs script which automates logging into multiple boxes to run a few commands. However, I'd like to have something run in Linux vs. our emulator. Below is my objective :): Our current .vbs script will look at an IP list .txt file on our PC, then login to... (1 Reply)
Discussion started by: birdboyee
1 Replies

4. Red Hat

How to access redhat Linux box graphically from windows box?

Hi I have a linux box and need to access from windows graphically # uname -a Linux pc-l416116 2.6.18-155.el5 #1 SMP Fri Jun 19 17:06:47 EDT 2009 i686 i686 i386 GNU/Linux What components do I need to install on Linux and windows to do that? TIA (6 Replies)
Discussion started by: magnus29
6 Replies

5. UNIX for Dummies Questions & Answers

Mounting Linux box to Linux box

Hi, I've been able to mount my linux box to a windows machine, but I can't seem to mount my linux box to another linux box I have. (I know I could scp, but for other reasons I need to do it this way) Samba is installed. Here is an example where I mount to a Win machine.--> works fine mount... (12 Replies)
Discussion started by: jdilts
12 Replies

6. Shell Programming and Scripting

script to monitor mount points on linux box

Hi, the following shell script is not working on linux box sugeestions appreciated. FILE1=/tmp/check1.txt FILE2=/tmp/check2.txt df -k | awk '{if (NR != 1) print $5 $6}' > ${FILE1} awk -F"%" '{if ($1 > 90) print "Warning: Filesystem " $2 " over 90% threshold (" $1 "%)"}' ${FILE1} >... (7 Replies)
Discussion started by: prakash.gr
7 Replies

7. Shell Programming and Scripting

ftp file starting with particular name on Windows box to Unix box using shell script

Hello all ! I'm trying to write a shell script (bash) to ftp a file starting with particular name like "Latest_" that is present on a Windows box to UNIX server. Basically I want to set this script in the cron so that daily the new build that is posted on the Windows box can be downloaded to the... (2 Replies)
Discussion started by: vijayb4u83
2 Replies

8. Linux

Local shell script need to be executed on a remote linux box

I need to execute a shell script on a remote linux box. But the shell script resides on the local linux box where I am currently logged in. Is there a way to do this? I know rsh <host> <command> can execute a command on the remote host. (6 Replies)
Discussion started by: rajeshomallur
6 Replies

9. Shell Programming and Scripting

Box A's perl script calling box B's shell script

Hi all, i have a perl script one server. I am running a cronjob to execute my perl script. #! /usr/bin/perl ... ... ... #call a shell script on another server How can i accomplish #? Do i have to issue a system (" ssh -l username server | shellscript.sh") in my shell script? or is there a... (1 Reply)
Discussion started by: new2ss
1 Replies

10. Shell Programming and Scripting

Script to Reboot a linux box from a windows box

HI All, I need a script to reboot a linux box from a windows box. The script needs to run automatically whenever a sitescope alerts with an error message. Have searched for this in the forums, but could not get something relative. Pls. let me know the various alternatives we have to do... (2 Replies)
Discussion started by: Crazy_murli
2 Replies
Login or Register to Ask a Question