Sponsored Content
Full Discussion: First script in a long time
Top Forums Shell Programming and Scripting First script in a long time Post 303009359 by andysensible on Wednesday 13th of December 2017 11:29:23 AM
Old 12-13-2017
Thanks for the feedback, I am almost there with it... I think I have a solution regarding the serial number.

can i set a default value for the serial number or last seen var if its null?

Code:
serial="FPLTL05YFCM5"
# get last seen value of ipad

lastseen=$(curl -s -X "GET" "https://cn705.awmdm.com/api/mdm/devices/serialnumber/$serial" -H "Authorization: Basic bmFnaW9zOm5ITXBZaVBiNHpGZ201WVk=" -H "aw-tenant-code:  Mg0dJDVw02tyPHhFqU8uS3t0ZzkRqJ8mjDHGplY68WI=" | xmllint --format -|grep LastSeen | awk -F "T|<" '{print $3}' | awk -F: '{printf "%1.0f",($1*60)+$2+($3%60)}')

elif [[ "$1" = '^[a-ZA-Z]*$' ]] || [[ -z "$lastseen" ]];
echo "Serial Number Invaild"
then exit 3;

and if the default value = 1 then I can exit out of the script?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script takes long time to complete

Hi all, I wrote this shell script to validate filed numbers for input file. But it take forever to complete validation on a file. The average speed is like 9mins/MB. Can anyone tell me how to improve the performance of a shell script? Thanks (12 Replies)
Discussion started by: ozzman
12 Replies

2. AIX

rcp gets hung for long time

Every evening I run a script in AIX production box, which executes below command: rcp prod_bkup.tar prodapp@IP:/data/appl/prod This will rcp a backup of around 11 GB from production to another machine (runs every evening so overwrites previous one). Just to keep the backup safe. Since 2-3 days,... (0 Replies)
Discussion started by: panchpan
0 Replies

3. Programming

Debug env for long time use

Hi, I'm pritty new to C, but a recent bug in a program i've been using has forced me to debug it. But I am unable to find a debugger that can act as a layer between the OS and the program to see whats going on.. The problem is that this piece of software makes a connection through localhost... (2 Replies)
Discussion started by: nephilimbe
2 Replies

4. Shell Programming and Scripting

<AIX>Problem in purge script, taking very very long time to complete 18.30hrs

Hi, I have here a script which is used to purge older files/directories based on defined purge period. The script consists of 45 find commands, where each command will need to traverse through more than a million directories. Therefore a single find command executes around 22-25 mins... (7 Replies)
Discussion started by: sravicha
7 Replies

5. Shell Programming and Scripting

help - exec time too long

Dear everyone... thanks to this forum I am able to do everyday more and more complex scripts...but now I come up with problem with optimisation.. problem 1 - optimise: here is my code: while read number do nawk -F "|" -v... (8 Replies)
Discussion started by: abdulaziz
8 Replies

6. UNIX for Dummies Questions & Answers

Job is taking long time

Hi , We have 20 jobs are scheduled. In that one of our job is taking long time ,it's not completing. If we are not terminating it's running infinity time actually the job completion time is 5 minutes. The job is deleting some records from the table and two insert statements and one select... (7 Replies)
Discussion started by: ajaykumarkona
7 Replies

7. Shell Programming and Scripting

How long ago since time - Using perl

echo "1337124526" | perl -pe 's/(\d+)/easttime($1)/e' the above gives a date and time. how can i subtract the date and time given by this command, from the current present date? can this be a one liner or as close to a one-liner as possible? (1 Reply)
Discussion started by: SkySmart
1 Replies

8. Shell Programming and Scripting

Kill long running script, if it crosses the threshold time

Hi, I need a script to kill the process if it running for long time. Inputs for the scripts: 1.test.sh (will be running fron cron scheduler) 2.1 hr (ie threshold_time - if the test.sh is running for more than 1 hr test.sh has to kill) Thanks, Divya (1 Reply)
Discussion started by: Divya Nochiyil
1 Replies

9. Shell Programming and Scripting

Expect script idles for a long time

the following code works sometimes. other times, it behaves mysteriously. when the script sshs to a box, it is suppose to automatically begin running the command it is told to run. but in this case, after this script logs into a host, it just sits there at the prompt and does not run the... (1 Reply)
Discussion started by: SkySmart
1 Replies

10. Shell Programming and Scripting

Killing the process if running for long time in script

I am running a script which will read the data from fail line by line and call the Java program by providing the arguments from the each line. The Java code is working fast for few records and for some records its getting hanged not providing response for morethan one hour. Currently am... (4 Replies)
Discussion started by: dineshaila
4 Replies
snfetch,v0.3.8(8)					      System Manager's Manual						 snfetch,v0.3.8(8)

NAME
snfetch - fetch articles. SYNOPSIS
snfetch [-r] [-t timeout] [-c depth] group [serial [max]] DESCRIPTION
snfetch expects to read NNTP from file descriptor 6, and write NNTP to file descriptor 7, which descriptors must have already been open. Articles retrieved are written to descriptor 1. Each article displayed is separated from the next by a dot on a line by itself. These articles are NNTP safe, in the sense that double-dot unquoting is not done, and all lines end in CR-LF. snfetch expects to begin it's NNTP speech by giving the GROUP command. The upstream server's greeting must have already been read some other way. Likewise, when snfetch is done, it will not send a QUIT command. The output is suitable for feeding to snstore. snfetch always checks the article ID of the prospective article before retrieving it. If the ID already exists in the ID database, the article will not be retrieved. Note that this does not guarantee that all articles retrieved will be unique. snfetch does not guarantee to leave the NNTP conversation in a decent state (there might be more data to read, but snfetch aborted part way). You will need to be root or own /var/spool/sn in order to run this program. It is not safe to direct the output of several snfetches to the same pipe descriptor, but a file descriptor is all right. OPTIONS
-t timeout snfetch will wait only timeout seconds (default 180) for data before giving up, if the server doesn't respond. -r Output in news batch format instead. All articles will take the #! rnews form only, even if there is just one article, all lines end in bare linefeed, and dot-unquoting is performed. -c depth Employ a command pipeline of depth depth. NNTP command pipelining is not officially sanctioned, so by default no pipeline is used. However, a pipeline with a depth greater than 0 will substantally reduce transaction latency if the server accepts it. A respectable value for depth might be between 1 and 5. ARGUMENTS
snfetch takes the name of a single newsgroup on its command line. If serial is given, this is taken to be the first article number on group on the server to fetch. If max is specified, this is taken to be the maximum number of articles to fetch. The first article retrieved may be after serial if max would be violated. If max is not specified, there is no limit. ENVIRONMENT VARIABLES
SNROOT If this is set and is not empty, the value is used in place of /var/spool/sn, the default news spool directory. FILES
/var/spool/sn/newsgroup/.serial If serial is not specified, the starting serial number is taken from the file /var/spool/sn/newsgroup/.serial. This defaults to 0 if the file can't be read. /var/spool/sn/newsgroup/.serial.tmp If snfetch exits with success (0), the new serial is written into this file. The original file /var/spool/sn/newsgroup/.serial is readonly by snfetch. /var/spool/sn/newsgroup/.max If max is not specified on the command line, max is read from this file. If the file cannot be read or does not exist, there is no limit. EXIT CODES
snfetch exits 1 on usage error, 2 on system failure, 3 on protocol error, 4 on read timeout, and 0 on success. SEE ALSO
snstore (8), snget (8) N.B. Harold Tay snfetch,v0.3.8(8)
All times are GMT -4. The time now is 01:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy