Sponsored Content
Full Discussion: Help on simple shell script
Top Forums Shell Programming and Scripting Help on simple shell script Post 302997072 by Aia on Sunday 7th of May 2017 12:17:29 PM
Old 05-07-2017
Quote:
Originally Posted by dcaccount
Hello,

I need to create one very simple shell script that checks if the first character of the file ./pump.txt is 0 and in that case gives a message.
If the first character is instead 1, it does give a different message.
I have written:
Code:
irr= head -c 1  ./pump.txt
if [[ "$irr" == "0" ]]; then
        echo "!!!!!!!!!! Disabled"
else
        echo "Enabled"
fi

It does not work.


Ps, the file ./pump.txt is generated by the following commands:
either echo "1" > "./pump.txt" or
echo "0" > "./pump.txt"

Can you please help me?
Thanks,
daniele
Try
Code:
irr=$(head -c 1  ./pump.txt)

Note: No space between `='.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

I need of a simple shell script

Hi, I need of a simple shell script to launch a perl script. The complet path of the script is: /export/home/x2693/project/v02/appliancemanagement.pl (2 Replies)
Discussion started by: Minguccio75
2 Replies

2. Shell Programming and Scripting

Need help in a simple shell script

Hi All I have requirement to write a shell script which would look for the userid which is logged in , and once the User id is found i would delete certain lines from a parameter file .. here is what iam using a=ps -o user | grep -v user | uniq then using an if condition and... (4 Replies)
Discussion started by: raghav1982
4 Replies

3. Shell Programming and Scripting

simple shell - how to get a parameter typed in a shell script

Hi, I am new to unix and using linux 7.2. I would like to create a script that would make it easyer for me to run my java programms. At the moment I have to type java myJavaprogram I am trying to write a script that will allow me to type something like this "myscript myJavaprogram" or maybe... (4 Replies)
Discussion started by: cmitulescu
4 Replies

4. Shell Programming and Scripting

Need help with a very simple shell script

Am VERY new to UNIX and need to know the answer to this particular question :- Write a short shell or perl script to do the following tasks: 4.1 Move all the files mentioned (there are other files in the directory) from their current directory to /home/selvarde/testfiles/ and add the file... (1 Reply)
Discussion started by: samdeb
1 Replies

5. Shell Programming and Scripting

Simple Shell Script

Hello Friends, I am writing a shell script which will grab a file if it exists and copies it to another folder and will append with current date. I have written but gives me error, plz help: -------------------------------------------- #!/usr/bin/sh source=/home/dev4rice/naveen/test1... (4 Replies)
Discussion started by: ganesh123
4 Replies

6. Shell Programming and Scripting

Help me with simple shell script.

Hello forum members, I have to redirect a output of command into a text file inside a script file but iam getting an errors.so please see below script and suggest me for corrections. #!/bin/ksh read IP_ADD echo nslookup $IP_ADD 2>&1| tee log1.txt cat /amex/gcst/siva/Testr/log1.txt... (6 Replies)
Discussion started by: rajkumar_g
6 Replies

7. Shell Programming and Scripting

Help with very simple Shell Script

Write a shell that receives as parameters two folder names. Copies the second folder as subfolder into the first one. Only folders and files with the '.txt' extension will be copied. Detect and avoid recursive copy. This is what I have to do and I don't know where to start. In fact, I started... (5 Replies)
Discussion started by: sharpsh07er
5 Replies

8. Shell Programming and Scripting

Help with simple Shell Script

Hi , I am in need of simple shell script that has one input file containing some words Input file 1 : ****ALEX***JOHN*******VIRGIL***** CHRITINE*****FAISAL*****DON***** ****ALEX***JOHN*******VIRGIL***** CHRITINE*****FAISAL*****DON***** ****ALEX***JOHN*******VIRGIL*****... (6 Replies)
Discussion started by: kmanjuna
6 Replies

9. Shell Programming and Scripting

Simple Shell Script? Someone help?

Write a shell script which adds up 10 numbers entered by the user and displays the result to the screen. You must use the read command to obtain the numbers from the user. Im a nooby noob (2 Replies)
Discussion started by: LinuxNubBrah
2 Replies

10. Shell Programming and Scripting

Simple Shell Script! Almost Done!

Hello, I am creating a shell script and I am almost done. I have certain things I want done in the shell but don't know how to finish it properly. Here is what I am aiming to do. I am aiming to have a shell that takes at least 3 parameters. The first two are the two words to replace (the... (3 Replies)
Discussion started by: ShellsNewb
3 Replies
PUMP(8) 						   Linux Administrator's Manual 						   PUMP(8)

NAME
pump - configure network interface via BOOTP or DHCP protocol SYNOPSIS
pump [-krRsd] [-c|--config-file FILE] [-h|--hostname HOSTNAME] [-i|--interface IFACE] [-l|--lease HOURS] [-m|--route-metric METRIC] [--lookup-hostname] [--no-dns] [--no-gateway] [--no-ntp] [--no-setup] [--release] [--renew] [--script= ISCRIPT] [--status] [--win-client-ident] pump [-?|--help] [--usage] DESCRIPTION
pump is a daemon that manages network interfaces that are controlled by either the DHCP or BOOTP protocol. While pump may be started manually, it is normally started automatically by ifup(8) for devices configured via BOOTP or DHCP. If pump is managing an interface, you can run it again to query the status of that interface. For example, pump -i eth0 --status will print the current status of device eth0. COMMAND LINE OPTIONS
switch long option description -? --help Show this help message -c --config-file=FILE Get configuration from FILE instead of /etc/pump.conf -d --no-dns Don't update DNS resolver configuration -h --hostname=HOSTNAME Request HOSTNAME -i --interface=IFACE Manage IFACE rather than eth0 --keep-up Keep the interface up when released -k --kill Kill daemon (and disable all interfaces) -l --lease=HOURS Request least time of HOURS --lookup-hostname Look up hostname in DNS -R --renew Renew lease immediately -r --release Release interface -m --route-metric=METRIC Metric to use on routes (normally 0) --no-gateway Don't configure a default route for this interface --no-resolvconf Don't use the resolvconf program to update resolv.conf --no-ntp Don't update ntp.conf --no-setup Don't set up anything --script=SCRIPT Call SCRIPT (or null string to disable) -s --status Display interface status --usage Display a brief usage message --win-client-ident Specify a Windows(tm)-like client identifier OPTION NOTES
The --lookup-hostname option causes pump to ignore the host and domain names returned by the server and instead to look these up in DNS using the IP address of the interface. The name that is looked up is used in forming the search line in the resolv.conf file. Thus, if either the --no-dns or domainsearch option is used then --lookup-hostname has no effect. Note that pump itself never sets the computer's hostname. CONFIGURATION FILE
You can tune the behavior of pump using a configuration file. By default pump reads /etc/pump.conf but you can change this using the --config-file option. The configuration file is line-oriented. Most lines contain a directive followed by zero or more arguments. Arguments are handled simi- larly to how shells handle command arguments, allowing the use of quotes and backslash escapes. Comments are allowed, and must begin with a # character. Spaces and tabs are ignored. Directives may be specified at two levels: global and specific. Global directives change pump's behavior for all of the devices that it manages whereas specific directives change pump's behavior for a single device. Later directives always override earlier ones. Here is an example configuration file: # sample /etc/pump.conf file domainsearch "my.own.org own.org at.work.com" retries 3 device eth1 { nodns } This configuration file tells pump to use a specific DNS search path rather than deriving one from the DHCP or BOOTP server response, to retry each request 3 times (for a total of 4 tries), and not to change the DNS configuration file when it's configuring the eth1 device. Here is a complete list of directives: device DEVICE Specify specific directives for DEVICE. This directive must be followed by a {, and the list of specific directives must end with a } on its own line. These directives may not be nested. domainsearch SEARCHPATH Use SEARCHPATH as the DNS search path instead of the domain name returned by the server or the domain part of the fully qualified hostname. keepup Keep the interface up when released. Normally pump brings the interface down when it releases its lease, but some daemons such as ifplugd or wpa_supplicant still need the interface to be up so that they can still work. nonisdomain Don't set the NIS domain. Normally pump sets the system's NIS domain if an NIS domain is specified by the DHCP server and the cur- rent NIS domain is empty or localdomain. nodns Don't update /etc/resolv.conf when the interface is configured. nogateway Ignore any default gateway suggested by the DHCP server for this device. This can be useful on machines with multiple devices. nontp Don't update /etc/ntp.conf when the interface is configured. nosetup Don't set up anything on the local machine as a result of DHCP operations. This implies nodns, nonisdomain, nogateway and nontp. This option is useful, for example, if you want to perform setup in customised scripts. noresolvconf Don't use the resolvconf program to update /etc/resolv.conf; instead, update /etc/resolv.conf directly. (This option is only rele- vant if --nodns is not used.) retries COUNT Retry each phase of the DHCP process COUNT times. timeout COUNT Don't let any one step of the DHCP process take more then COUNT seconds. script FILE Condition arg1 arg2 arg3 lease up eth0 1.2.3.4 renewal renewal eth0 2.3.4.5 release down eth0 When events occur in negotiation with the server, call the executable FILE. Scripts are called when a lease is granted, when a renewal is negotiated, and when the interface is brought down and the address released. The script is called with two or three arguments, depending on the condition, as documented in the table above. LOGGING
The program logs a good deal of information to syslog, much of it at the DEBUG level. If you're having trouble, it's a good idea to turn up syslog's logging level. BUGS
At startup pump tries to detect whether another instance of itself is running. If the UNIX domain socket (normally /var/run/pump.sock) does not exist, pump tries to connect to tcp/127.0.0.1:68. If it is also unreachable (possibly due to packet filtering), pump will issue a warning to stderr and assume that there is no instance of itself running. Probably limited to Ethernet, might work on PLIP, probably not ARCnet and Token Ring. The configuration file should let you do more things. Submit bug reports at the Bug Track link at http://developer.redhat.com/ QUIBBLE
A pump, like a boot[p], is something you wear on your foot. Some of us like the name (I know, hard to believe)! Linux 26 August 2004 PUMP(8)
All times are GMT -4. The time now is 07:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy