Sponsored Content
Top Forums Shell Programming and Scripting Value of variable is NULL, but test doesn't seem to recognize Post 302623637 by radoulov on Saturday 14th of April 2012 07:36:17 AM
Old 04-14-2012
Try:

Code:
read -p 'Enter any number, please: ' number
sleep 1
number=$( tr -d 0-9 <<< "$number" )
test -z "$number" && 
  echo "Thank you" || 
    echo "This is not a number"

Actually you could avoid calling external commands in this case:

Code:
read -p 'Enter any number, please: ' number
sleep 1
test -z "${number//[0-9]}" && 
  echo "Thank you" || 
    echo "This is not a number"

P.S. The code above uses non standard shell features, but that shouldn't be
a problem, considering that the original post uses non standard features too Smilie
This User Gave Thanks to radoulov For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Doesn't recognize the mv command

I'm nearly finished my program i've got everything in place and than when i run it it comes back with the reply mv: command not found. This is the code that seems to be causing the problem. elif then echo "There are more than one '$1' files in the system." echo "Please... (2 Replies)
Discussion started by: zoolz
2 Replies

2. Shell Programming and Scripting

test Null variable

hi forum i beginning with script and i want test un null variable in a schell i just don t know the syntax here is a litle example y=test echo $y unset y echo $y (so here Y = Null) if Y=Null then echo "y is null" exit fi (1 Reply)
Discussion started by: kykyboss
1 Replies

3. HP-UX

HP-UX 11.11: X doesn't recognize mouse and keyboard

hi folks, i've got a blank hp visualize C3000 workstation and installed HP-UX 11.11. When I want to start X, I get the following error message: # X Fatal server error: Couldn't open X pointer device! Is one attached? I've connected an mouse and a keyboard with an usb/ps2 connector.... (5 Replies)
Discussion started by: grisu
5 Replies

4. Shell Programming and Scripting

how to check null variable

korn shell If then update_smartcare_user_password "$u_id" else echo "Not a database user" fi i get this error Syntax error at line *** : `then' is not expected. what should i do. I want to check whether $a is null or not. (2 Replies)
Discussion started by: sachin.gangadha
2 Replies

5. Programming

Kernel module - How to test if file doesn't exist

Hey, I'm currently getting into some kernel module progamming. As a little exercise I want to read the headers out of an ELF file. My code is very simple, here is the important part: struct file *fp; /* ... */ fp = filp_open("some/file/on/my/pc", O_RDONLY, 0); if(fp == NULL) { ... (15 Replies)
Discussion started by: disaster
15 Replies

6. Shell Programming and Scripting

Expect doesn't recognize a password prompt

Hi. Here is beginning of my script #!/usr/local/bin/expect -- set timeout 15 spawn /usr/local/account.sh -n modify expect "Password:" {send "mypassword\r"} But due to some terminal control sequences (or something else, dunno exactly) my password prompt is looking like this: and expect... (3 Replies)
Discussion started by: urello
3 Replies

7. Shell Programming and Scripting

[Solved] If doesn't evaluate the first test

Good afternoon, I am tearing hair out over this. It should be so simple. I have an if statement to evaluate whether or not replication is working. I am testing variables from mysql to see if they are both "Yes". I have put some echo statements in to see how far the code proceeds. It always... (6 Replies)
Discussion started by: jimm
6 Replies

8. Shell Programming and Scripting

How to test that a string doesn't contain specific characters?

Hi ! :) I made this : #!/bin/bash rsa_dir="/etc/openvpn/easy-rsa/" rsa_key_dir="/etc/openvpn/easy-rsa/keys/" ccd_dir="/etc/openvpn/ccd/" regex_special_char='' cd $rsa_dir while read -p "Please can you enter the vpn's username : " username ] || ] || ] || ] do echo "Your entry... (10 Replies)
Discussion started by: Arnaudh78
10 Replies

9. IP Networking

DNS problem : ping doesn't recognize hostname

I have vmware on my windows PC ( hostname : acer ). vmware has RHEL 7 ( hostname : rhel7 ) installed recently. RHEL IP configuration IP : 192.168.5.128 Netmask : 255.255.255.0 ssh to rhel7 works from acer using putty resolve.conf cat /etc/resolv.conf nameserver 192.168.5.1 host... (12 Replies)
Discussion started by: hiten.r.chauhan
12 Replies
IRSEND(1)							   User Commands							 IRSEND(1)

NAME
irsend - basic LIRC program to send infra-red commands SYNOPSIS
irsend [options] DIRECTIVE REMOTE CODE [CODE...] DESCRIPTION
Asks the lircd daemon to send one or more CIR (Consumer Infra-Red) commands. This is intended for remote control of electronic devices such as TV boxes, HiFi sets, etc. DIRECTIVE can be: SEND_ONCE - send CODE [CODE ...] once SEND_START - start repeating CODE SEND_STOP - stop repeating CODE LIST - list configured remote items SET_TRANSMITTERS - set transmitters NUM [NUM ...] SIMULATE - simulate IR event REMOTE is the name of a remote, as described in the lircd configuration file. CODE is the name of a remote control key of REMOTE, as it appears in the lircd configuration file. NUM is the transmitter number of the hardware device. For the LIST DIRECTIVE, REMOTE and/or CODE can be empty: LIST "" "" - list all configured remote names LIST REMOTE "" - list all codes of REMOTE LIST REMOTE CODE - list only CODE of REMOTE The SIMULATE command only works if it has been explicitly enabled in lircd. -h --help display usage summary -v --version display version -d --device use given lircd socket [/var/run/lirc/lircd] -a --address=host[:port] connect to lircd at this address -# --count=n send command n times EXAMPLES
irsend LIST DenonTuner "" irsend SEND_ONCE DenonTuner PROG-SCAN irsend SEND_ONCE OnkyoAmpli VOL-UP VOL-UP VOL-UP VOL-UP irsend SEND_START OnkyoAmpli VOL-DOWN ; sleep 3 irsend SEND_STOP OnkyoAmpli VOL-DOWN irsend SET_TRANSMITTERS 1 irsend SET_TRANSMITTERS 1 3 4 irsend SIMULATE "0000000000000476 00 OK TECHNISAT_ST3004S" FILES
/etc/lirc/lircd.conf Default lircd configuration file. It should contain all the remotes, their infra-red codes and the corresponding timing and wave- form details. DIAGNOSTICS
If lircd is not running (or /var/run/lirc/lircd lacks write permissions) irsend aborts with the following diagnostics: "irsend: could not connect to socket" "irsend: Connection refused" (or "Permission denied"). SEE ALSO
The documentation for lirc is maintained as html pages. They are located under html/ in the documentation directory. lircd(8), mode2(1), smode2(1), xmode2(1), irrecord(1), irw(1), http://www.lirc.org. irsend 0.9.0-pre1 October 2010 IRSEND(1)
All times are GMT -4. The time now is 03:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy