Sponsored Content
Top Forums Shell Programming and Scripting Control structures and scripting question.. Post 302369469 by SlapnutsGT on Sunday 8th of November 2009 07:56:45 PM
Old 11-08-2009
Quote:
grep -q "^$apname" auto.parts && echo "is in parts"
Thanks for reply, the grep code is close to working, im just getting problem now where it always says part is duplicated, but hopefully I can figure it out from here.

Quote:
Morever: if you are entering "100 Brake", you need to split the quantity from the part.

Try this
Code:
echo "Enter qty part"
read line
echo "You typed $line"
set $line
echo $1 
echo $2

I did a poor job of explaining, I don't need to enter quantities, I was just figuratively saying my busted script was allowing more then one to be entered.

But, thanks for the help, hopefully I can get it from here now that I'm aware about specifying the file I gotta look into.

---------- Post updated at 07:56 PM ---------- Previous update was at 06:40 PM ----------

OK! I'm still messing with it and its not working, it keeps telling me everything is duplicated no matter what I type.

My code looks like:
Code:
#bin/sh
stop=0
while test $stop -eq 0
do
echo "Please enter auto part name:"
read apname
if [ "grep -q "$apname" auto.parts" ]
then
        echo -e "Part already entered into inventroy.\n"
        echo -e "Duplicate parts not allowed.\n"
        echo -e "Returning to edit menu...\n"
        stop=1
else
        echo -n "Please enter operator's name:"
        read opname
        status="Part Available"
        cdate=""
        bname=""
        echo ${apname}:${opname}:${status}:${cdate}:${bname} >> auto.parts
        echo -e "A new auto pat has been added to inventory!\n"
fi
done

Sorry to be a bother but this is really annoying me!

Is there a negate expression I should be using in my else statement? Something like:
Code:
grep -q "<$apname is not in file>" auto.parts

If I don't need it, what is the regular expression to see if the string is NOT in a file just so I will know it for future reference? Tried searching but could not find anything.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

another scripting question

I am writing a script that will identify the oldest file in a directory. Here's the syntax: #!/bin/ksh cd directory chmod 777 * ls -r -1t > file1 sed -n -e "1P" < file1 > file2 So my problem is, now I have file2, which contains the name of the oldest file in the directory. How do I use,... (1 Reply)
Discussion started by: kristy
1 Replies

2. Shell Programming and Scripting

another scripting question

Hello I am working on cleaning up permissions on Oracle mountpoints and datafiles in unix. I am looking for a script or a scripting idea to 1st. 1. grep for owner oracle 2. ensure its a directory owned for oracle 3. chmod 750 on the oracle owned directory. 4. grep for oracle files, etc... (3 Replies)
Discussion started by: jigarlakhani
3 Replies

3. Shell Programming and Scripting

scripting question

I'm new to shell scripting and am having a problem trying to do something in C shell. I want to write a script that will input something instead of a user doing it. For example, using the command 'write' the user is supposed to type something to be sent to another user. I want a script to be able... (3 Replies)
Discussion started by: batmike
3 Replies

4. UNIX for Dummies Questions & Answers

FTP access & control question

Folks; I need some help with these: 1. understanding how to control access rights and manage visibility using FTP in Solaris, in other words, I need to use FTP in Solaris to be able to give some users access to add/modify data to/from the UNIX server. 2. How can i control the space allowed for... (2 Replies)
Discussion started by: Katkota
2 Replies

5. UNIX for Dummies Questions & Answers

Scripting question

folks; I have a script to remove any files that older than 14 days then move any files that younger than 7 days to another directory. but for some reason it doesn't move the files, when i do it manually it works but not through the script. i tried 2 different ways in writing the move part but it... (6 Replies)
Discussion started by: Katkota
6 Replies

6. Linux

SSH remote control question

I am pretty new to linux so forgive me for asking a basic question :P I am using SSH to control 40 machines. What i am trying to do is remotely bash a shell script on each machine. I am using a for loop to bash every script, code as follows. code in host machine runallworkers.sh: ... ... (2 Replies)
Discussion started by: mgsolid
2 Replies

7. Shell Programming and Scripting

Scripting question

Preview of command prompt f ---> to start ferret q----> to stop ferret asp@nex:~$ f NOAA/PMEL TMAP FERRET v6.82 Linux 2.6.18-308.8.2.el5PAE 32-bit - 08/03/12 3-Dec-12 16:44 yes? go my.jnl yes?column=4/skip=1/type=num,text ............filename.txt ---... (4 Replies)
Discussion started by: nex_asp
4 Replies

8. Shell Programming and Scripting

Scripting question

hi all, I am writing a script and beginner in shell scripting. I have tried the below script. could you please check and let me know whether the below scirpt is correct. Unix details : HP Unix Input file. cat input.txt | tail -4 HTS40002.W1978.PROM HTS40003.W1978.PROM... (17 Replies)
Discussion started by: arun888
17 Replies

9. UNIX for Advanced & Expert Users

Question for expert only in Access control list

If I'm the admin for the financial system and I want to configure authorization pf file system permission.Also, The first rule is that Managers and clerks can read and write billings for all cases. The second rules is that Paralegals and administrative assits can read and write billings only on... (2 Replies)
Discussion started by: mecnio
2 Replies

10. SCO

Emacs Question; Control-G Not Working

Hi! I am using Emacs 22.3.1 and the Control-G command will not work to cancel. I took my init.el file out of the mix and it stills does not work. I am not sure when I upgraded from 20.4 to 22.3.1, if it worked, but it certainly does not now. Any thoughts... (6 Replies)
Discussion started by: trolley
6 Replies
PYFORMEX(1)						      text and X11 processing						       PYFORMEX(1)

NAME
pyformex - generate and transform 3D geometry using Python scripts SYNOPSIS
pyformex [options] [ [ file [args] ] ...] DESCRIPTION
This manual page documents briefly the pyformex command. pyFormex is a program for generating, transforming and manipulating large geometrical models of 3D structures by sequences of mathematical operations. Thanks to a powerful (Python based) scripting language, pyFormex is very well suited for the automated design of spatial frame structures. It provides a wide range of operations on surface meshes, like STL type triangulated surfaces. There are provisions to import medical scan images. pyFormex can also be used as a pre- and post-processor for Finite Element analysis programs. Finally, it might be used just for creating some nice graphics. Using pyFormex, the topology of the elements and the final geometrical form can be decoupled. Often, topology is created first and then mapped onto the geometry. Through the scripting language, the user can define any sequence of transformations, built from provided or user defined functions. This way, building parametric models becomes a natural thing. While pyFormex is still under development, it already provides a fairly stable scripting language and an OpenGL GUI environment for dis- playing and manipulating the generated structures. OPTIONS
The pyformex command follows the usual GNU command line syntax, with long options starting with two dashes ('-'). The non-option arguments are filenames of existing pyFormex scripts, possibly followed by arguments, that will be executed by the pyFormex engine. If a script file uses arguments, it is responsible for removing the arguments from the list. A summary of the most important options is included below. A complete overview is can be found from the 'pyformex -h' command. For a com- plete description of the use and operation of pyFormex, see the online documentation at http://pyformex.org/doc or the documentation included with the distribution. --gui start the GUI (default if no file argument is given) --nogui do not load the GUI (default if a file argument is given) --interactive, -i Go into interactive mode after processing the command line parameters. This is implied by the --gui option. --config=<file> Read configuration settings from <file>, if it exists. --nodefaultconfig Skip the default site and user config files. This option can only be used in conjunction with the --config option. --redirect Redirect standard output to the message board (ignored with --nogui) --debug display debugging info to standard output --whereami Show where the pyformex package is installed and exit --detect Show detected helper software and exit --version Show the program's version number and exit. --help, -h Show the help message and exit. SEE ALSO
http://pyformex.org/doc/ AUTHORS
pyFormex is developed by Benedict Verhegghe with the help of the other pyFormex project members: Gianluca De Santis, Francesco Iannaccone, Peter Mortier, Tomas Praet, Sofie Van Cauter, Wenxuan Zhou. AUTHOR
Benedict Verhegghe <benedict.verhegghe@ugent.be>. This manual page was written for the Debian project (and may be used by others). COPYRIGHT
GPL v3 or higher 0.1 2011-12-29 PYFORMEX(1)
All times are GMT -4. The time now is 06:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy