Hi Don...
You are of course correct in what you have quoted. I was well aware of my sleep alternative's limitations so I decided to embed a delay into a shell script. You suggested a C program to do the job, so here goes...
Code:
#!/bin/sh
# delay <milliseconds>
# MacBook Pro, 13 Inch, Circa August 2012, OSX 10.7.5, using sh and limited /bin/echo command.
clear
# Use /bin/echo here for minimalist echo command.
/bin/echo '/* delay.c */
/* Usage:- delay <milliseconds[0 to 1000000]> */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
unsigned int milliseconds;
milliseconds = 0;
/* This allows for NULL millisecond argument and more arguments too. */
if (argc <= 1 || argc >= 3)
{
printf ("\nUsage:- delay <milliseconds[0 to 1000000]>\n\n");
return 1;
}
/* Check for number of characters, no less than 1 and no more than 7. */
if (strlen(argv[1]) <= 0 || strlen(argv[1]) >= 8) (argv[1]) = "0";
/* Characters in function atoi() returns integer 0. */
milliseconds = atoi(argv[1]);
/* Finally, ONLY allow 0 to 1000000 range. */
if (milliseconds <= 0 || milliseconds >= 1000001) milliseconds = 0;
usleep (milliseconds * 1000);
return 0;
}' > /tmp/delay.c
echo "Show C source..."
cat /tmp/delay.c
echo "Compile the C source..."
gcc /tmp/delay.c -o /tmp/delay
ls -l /tmp/delay*
echo "Delay for 3 seconds - /tmp/delay 3000..."
/tmp/delay 3000
echo "Return code is $?..."
echo "Now show error report - /tmp/delay..."
/tmp/delay
echo "Return code is $?..."
Results:-
Code:
Last login: Mon Jul 11 22:09:24 on ttys000
AMIGA:barrywalker~> cd Desktop/Code/Shell
AMIGA:barrywalker~/Desktop/Code/Shell> ./mS_delay.sh
Show C source...
/* delay.c */
/* Usage:- delay <milliseconds[0 to 1000000]> */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
unsigned int milliseconds;
milliseconds = 0;
/* This allows for NULL millisecond argument and more arguments too. */
if (argc <= 1 || argc >= 3)
{
printf ("\nUsage:- delay <milliseconds[0 to 1000000]>\n\n");
return 1;
}
/* Check for number of characters, no less than 1 and no more than 7. */
if (strlen(argv[1]) <= 0 || strlen(argv[1]) >= 8) (argv[1]) = "0";
/* Characters in function atoi() returns integer 0. */
milliseconds = atoi(argv[1]);
/* Finally, ONLY allow 0 to 1000000 range. */
if (milliseconds <= 0 || milliseconds >= 1000001) milliseconds = 0;
usleep (milliseconds * 1000);
return 0;
}
Compile the C source...
-rwxr-xr-x 1 barrywalker wheel 8824 11 Jul 22:14 /tmp/delay
-rw-r--r-- 1 barrywalker wheel 802 11 Jul 22:14 /tmp/delay.c
Delay for 3 seconds - /tmp/delay 3000...
Return code is 0...
Now show error report - /tmp/delay...
Usage:- delay <milliseconds[0 to 1000000]>
Return code is 1...
AMIGA:barrywalker~/Desktop/Code/Shell> _
Hello,
I am trying to convince my boss to stop allowing our users to login as root (superuser). Currently our users login to our unix server with their own account, then as needed, they will do an su and put in the root password.
This scares me, for a bunch of reasons. Mainly, one is that we... (1 Reply)
In different online sources, I found bits and pieces of information about those square and angular brackets and pipes. From what I have read, I can conclude it looks like this:
1. Options outside any brackets are mandatory
2. Options inside these < .. > are mandatory too
3. Options inside ... (4 Replies)
From the nessus scanner tool report i got below vulnerability
PCI DSS Compliance : Insecure Communication Has Been Detected
http://www.tenable.com/plugins/index.php?view=single&id=56208
As per the description given in above link - I am not able to understand
How to find insecure port... (2 Replies)
Hi i am in new to Linux world . I have been assigned to a project to find out a tool that will fulfill the PCI compliance for Linux servers for Audit process. anyone have any recommendation on that. Do Rad hat have any native application or plug-ins which we can use for that. (1 Reply)
I need to set password compliance for some servers in my company.
However, the requirements are that we need to set different password policies for 3 different user groups within the company. These are :
System Users: i.e root, etc
Batch/Application Users: oracle, bscs, etc
Standard User:... (0 Replies)