MRP shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting MRP shell script
# 1  
Old 08-13-2015
MRP shell script

Hello,
I am in need of a simple shell script for my job. When given product quantity is shipped from factory, I want to reduce related subparts existing in product tree and keep my warehouse stocks up to date by running a script.

Scenario:
I sold and produced 5pcs of the product nr101.

Here is its product tree:
product_nr101.xls
first column shows subpart nr , partname and quantity in use in product nr101:
Code:
144126201	PART NAME1	4,00	PCS
144126202	PART NAME2	4,00	PCS
144126203	PART NAME3	4,00	PCS
144126204	PART NAME4	1,00	PCS
144126205	PART NAME5	2,00	PCS
144126206	PART NAME6	6,00	PCS
144126207	PART NAME7	4,00	KG
144126208	PART NAME8	1,00	KG
144126209	PART NAME9	0,10	KG
144126210	PART NAME10	1,00	PCS

Warehouse.xls
First column is subpart nr and second column is showing how many pcs of part I have in my stocks.
Code:
144126201	50,00	PCS
144126202	40,00	PCS
144126203	40,00	PCS
144126204	50,00	PCS
144126205	200,00	PCS
144126206	200,00	PCS
144126207	100,00	KG
144126208	100,00	KG
144126209	100,00	KG
144126210	230,00	PCS

When 5pcs of product101 is shipped, it will multiply quantity in each row, will find it in warehouse.xls and reduce the quantity.

I tried to write something in shell but dont know how to proceed:

Code:
#!/bin/sh
echo "enter shipped product code"
read productcode
echo "enter how many pcs product shipped"
read quantity
.....?....

I would appreciate if you could help me.


Thanks
Boris
# 2  
Old 08-13-2015
Are you sure you want to do an MRP thingy in shell? Or is this an exercise/assignment?

However, given you'd replace the commas in your files by dots ("."), would this come close to what you need:
Code:
awk '
BEGIN           {printf "product code: "; getline PC  < "/dev/tty"
                 printf "qty shipped: ";  getline QTY < "/dev/tty"
                }

FNR==NR         {CONS[$1]=$4 * QTY
                 next
                }

                {$2-=CONS[$1]
                 printf "%s\t%8.3f\t%s\n", $1, $2, $3
                }
' file1 file2
product code: nr101
qty shipped: 5
144126201      30.000    PCS
144126202      20.000    PCS
144126203      20.000    PCS
144126204      45.000    PCS
144126205     190.000    PCS
144126206     170.000    PCS
144126207      80.000    KG
144126208      95.000    KG
144126209      99.500    KG
144126210     225.000    PCS

?

Last edited by RudiC; 08-13-2015 at 01:52 PM..
# 3  
Old 08-13-2015
Thanks Rudic,
I will give it a try at my end.
Normally that was not directly related to unix/shell script but I want to do such things in linux. At the office, I use a licenced software and we are waiting for having an education program being directed by the company. Do you recommend excel?

Again and again.... many thanks for your effort
Boris
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell script newbie- how to generate service log from shell script

Hi, I am totally a newbie to any programming languages and I just started an entry level job in an IT company. One of my recent tasks is to create a script that is able to show the log file of linux service (i.e. ntpd service) lets say, if I run my script ./test.sh, the output should be... (3 Replies)
Discussion started by: xiaogeji
3 Replies

2. Shell Programming and Scripting

How to write config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

3. UNIX for Dummies Questions & Answers

How to write Config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

4. Shell Programming and Scripting

Unable to pass shell script variable to awk command in same shell script

I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist. diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff | awk... (2 Replies)
Discussion started by: Ashunayak
2 Replies

5. Shell Programming and Scripting

Correct shell script to Call One shell script from another shell script

Hi All, I have new for shell scripting. Problem : I have one scrip at serv1 and path of server is /apps/dev/provimage/scripts and script name:extract_ancillary.bat. I need to call this script at server2(my working server) and execute at server2 . Please let me know how to build the... (5 Replies)
Discussion started by: Vineeta Nigam
5 Replies

6. Shell Programming and Scripting

How to use ssh execute other shell script on other host (shell script include nohup)?

i want use ssh on the host01 to execute autoexec.sh on the host02 like following : host01> ssh host02 autoexec.sh autoexec.sh include nohup command like follwing : nohup /home/jack/deletedata.sh & after i execute ssh host02 autoexec.sh one the host01. i can't found deletedata.sh... (1 Reply)
Discussion started by: orablue
1 Replies

7. UNIX and Linux Applications

CK-ERP (Open Source Edu / ERP / CRM / MRP) v.0.30.1 released

Hi, folks, A new release, v.0.30.1, of CK-ERP, has been posted, at SourceForge.Net, sourceforge.net/projects/ck-erp . New features comprise seven new modules (ck-teacher, ck-counsellor, ck-student, ck-applicant, ck-family, ck-registrar, ck-eduadmin) for deployment within educational... (0 Replies)
Discussion started by: chiukay
0 Replies

8. Shell Programming and Scripting

invoking a shell script inside cgi shell script

Hi, I have an HTML form through which I get some text as input. i need to run a shell script say script.sh inside a perl-cgi script named main_cgi.sh on the form input. I want to write the contents of the form in a file and then perform some command line operations like grep, cat on the text... (2 Replies)
Discussion started by: smriti_shridhar
2 Replies

9. Shell Programming and Scripting

ssh root@mrp-gateway problems

Dear friends, exec 0<$SuppFile while read LINE do echo $LINE gatewayArchive=`ssh root@mrp-gateway "cd /usr/local/apache/data/PLAT/MIMUS/upload/PROD/archive && ls $LINE"` echo "gateway files :"$gatewayArchive done this loop is not repeating when i use ssh root@mrp-gateway line of code.... (1 Reply)
Discussion started by: kittusri9
1 Replies
Login or Register to Ask a Question