Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
getting same.....
$ sh foo.sh
foo.sh: line 3: typeset: -A: invalid option
typeset: usage: typeset [-afFirtx] [-p] name[=value] ...
Just testing
======================
but when i tried with this:
$ ./foo.sh
Just testing
no error.....why so?
If you use sh sriptname.sh then sh is used and _not_ the shell in the first line of the script. sh is a link to bash (on most systems).
To run a script you use scriptname.sh (assuming the script can be found in the PATH setting) or ./scriptname.sh (assuming you stand in the directory the script is in).
You could also use /full/path/to/criptname.sh
some other person is working on that project now.
anyway, i'll be in touch with you, as i wanted to be like you in the scripting world.
meanwhile i am going through your linux related collection in your blogs...
will post you the queries here... Thanks a lot once again... :-)
Last edited by santosh0782; 12-07-2013 at 03:52 AM.
That is too bad. But looking at your level of scripting knowledge and the complexity of the work that needs to be done this probably isn't totally unexpected.
On the up side: You learned some valuable things while working on this project.
Quote:
meanwhile i am going through your linux related collection in your blogs...
The Bash section of my blog has some valuable info. Also have a look at the Linux Shell Scripting Tutorial link in the Shell section.
The only way to learn scripting is practise. Start with simple things, have a look at other scripts and try to understand how things are done.
Quote:
Thanks a lot once again... :-)
You're welcome.
Last edited by druuna; 12-07-2013 at 08:32 AM.
Reason: Fixed a weird sentence
I have a script which takes data for every 1 hour, if i want to make the same script to take data for every 30 minutes then where should i make the changes..could you please advise?
=================================
data files used above contains the data as:
1. data in channel file(for AS2,DCP,KIVR and CCCD):
2893907 DCP
4451746 CCCD
4592242|4592267|4592275 KIVR
2. data in audit.tmp file(first column is the date with HHMMSS):
now with this data file the above script is taking the data during that particular hour and accumulating it and now the requirement is to add the data after every 30 minutes.(above, i have given the half part of the script, because if it works for them then will implement the same to others)
Last edited by santosh0782; 12-19-2013 at 03:00 AM.
@santosh0782: There are too many unknowns to be able to help you with this.
A few examples:
- What do the audit.log files look like,
- Where does channel come from and what's the content,
- What does convert_dt.pl do,
- What is the content of pay_dt.txt and pay_dt1.txt.
Some code doesn't seem to make sense. A few examples:
- Is this correct: tody=`ksh today`,
- Why is the loop present, i is never used inside the loop:
A lot of the code can be written more efficient, but that might be considered an aesthetic issue (although it would make the code faster and easier to read).
In general: The whole script is build with a 1 hour time frame in mind which makes changing it into a 30 minute driven script rather hard (if not impossible). I would suggest having a good look at the data you have to start with (which seems to be the audit logs) and start fresh from there.
Here are the answers for the questions you asked:
1. What do the audit.log files look like,
ANS--> audit.log its data going in audit.tmp(have sent the sample of audit.tmp(first column is the date with HHMMSS))
audit.tmp:
20131218000124,131218000127,100,992261,476248******8322,,,1608,809087,3505,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218000133,131218000137,200,992612,475714******5463,,,1604,MERCHANT-DECLINE,50000,4451746,826,826,106,8,00,CV2200,8,2,4,4,1,1,1,1
20131218000322,131218000325,100,992574,475117******1080,,,1410,223569,16462,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218000326,131218000329,100,992642,675922******8589,,0812,1507,518000,44926,2893907,826,826,000, 8,00,CV2100,8,2,2,2,1,1,1,1
20131218000403,131218000406,100,992613,465911******2007,,,1608,040485,17495,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218000420,131218000423,100,992520,454313******3120,,,1804,316085,5000,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218000554,131218000558,100,992575,446291******7818,,,1607,018936,2500,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218000643,131218000646,100,992614,557351******3868,,,1405,615000,10000,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218000654,131218000656,100,992521,456726******4299,,,1605,015620,25000,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218000657,131218000700,100,992576,453978******6367,,,1502,065904,20000,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218000657,131218000700,100,992643,475130******3652,,,1511,451675,50000,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218000658,131218000701,100,992615,475130******3272,,,1604,823951,7000,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218000812,131218000814,200,992577,475714******5463,,,1605,DECLINE,50000,4451746,826,826,002,4,0 0,CV2200,8,1,1,1,,,,
20131218000921,131218000924,200,992644,475714******5463,,,1604,163530,50000,4451746,826,826,000,8,00 ,CV2200,8,2,2,2,1,1,1,1
20131218000938,131218000940,100,992616,446238******5817,,,1509,DECLINE,12000,2893907,826,826,002,4,0 0,CV2100,8,4,1,1,,,,
20131218000950,131218000953,100,992645,492181******4879,,,1510,018238,8700,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218001045,131218001049,100,992578,446271******5013,,,1511,018676,5000,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218001117,131218001120,100,992617,465861******1108,,,1609,011940,2500,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218001132,131218001135,200,992646,492181******4626,,,1402,018110,75299,4451746,826,826,000,8,00 ,CV2200,8,2,2,2,1,1,1,1
20131218001136,131218001139,100,992618,475128******9422,,,1312,138256,7000,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218001205,131218001208,200,992619,465935******9305,,,1605,035936,35000,4451746,826,826,000,8,00 ,CV2200,8,2,2,2,1,1,1,1
20131218001212,131218001215,100,992647,475130******9247,,,1503,547678,20000,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218001245,131218001248,100,992579,475129******1112,,,1610,737787,7127,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218001421,131218001423,100,992772,456726******0367,,,1511,DECLINE,4931,2893907,826,826,002,4,00 ,CV2100,8,1,1,1,,,,
20131218001423,131218001426,100,992580,557349******9016,,,1406,494600,11000,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218001428,131218001431,100,992648,465902******3079,,,1607,043034,2200,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218001507,131218001510,100,992620,453978******8618,,,1502,050914,60000,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218001829,131218001832,100,992621,475130******6976,,,1506,669353,290810,2893907,826,826,000,8,0 0,CV2100,8,2,2,2,1,1,1,1
20131218001841,131218001844,100,992773,475130******2744,,,1511,169092,2496,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218001944,131218001947,100,992649,446277******0158,,,1405,785750,120000,2893907,826,826,000,8,0 0,CV2100,8,2,2,2,1,1,1,1
20131218001946,131218001949,100,992822,456726******4767,,,1512,787730,5000,2893907,826,826,000,8,00, CV2100,8,2,2,2,1,1,1,1
20131218002305,131218002308,200,992650,446238******5817,,,1509,018086,12000,4451746,826,826,000,8,00 ,CV2200,8,2,2,2,1,1,1,1
20131218002317,131218002320,100,992823,475117******8466,,,1504,288632,16000,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218002333,131218002336,100,992774,465901******3046,,,1606,033514,43707,2893907,826,826,000,8,00 ,CV2100,8,2,2,2,1,1,1,1
20131218002527,131218002529,200,992775,475127******6564,,,1603,DECLINE,131550,4451746,826,826,002,4, 00,CV2200,8,1,1,1,,,,
2. Where does channel come from and what's the content,
Ans: data in channel file(for AS2,DCP,KIVR and CCCD):
2893907 DCP
4451746 CCCD
4592242|4592267|4592275 KIVR
3.What does convert_dt.pl do
Ans:
convert_dt.pl:
Code:
#!/usr/bin/perl
$num_args = $#ARGV + 1;
die "Usage: this-program epochtime (something like '1219822177')" if
($num_args != 1);
$epoch_time = $ARGV[0];
($sec,$min,$hour,$day,$month,$year) = localtime($epoch_time);
# correct the date and month for humans
$year = 1900 + $year;
$month++;
printf "%02d-%02d-%02d %02d\n", $year, $month, $day, $hour;
4. what does convert_dt1.pl do
Ans:convert_dt1.pl:
Code:
#!/usr/bin/perl
$num_args = $#ARGV + 1;
die "Usage: this-program epochtime (something like '1219822177')" if
($num_args != 1);
$epoch_time = $ARGV[0];
($sec,$min,$hour,$day,$month,$year) = localtime($epoch_time);
# correct the date and month for humans
$year = 1900 + $year;
$month++;
printf "%02d%02d%02d%02d\n", $year, $month, $day, $hour;
5. What is the content of pay_dt.txt and pay_dt1.txt.
sample content for pay_dt.txt:
2013-12-19 05
Sample content for pay_dt1.txt
2013121905
6. Why is the loop present, i is never used inside the loop.
ANS: You are right this is never used.
@santosh0782: You seem to have missed the important part of my previous reply:
Quote:
Originally Posted by druuna
In general: The whole script is build with a 1 hour time frame in mind which makes changing it into a 30 minute driven script rather hard (if not impossible). I would suggest having a good look at the data you have to start with (which seems to be the audit logs) and start fresh from there.
BTW: (ksh) today isn't a internal command. I'm guessing that today is a self written (ksh?) script. Be careful when using this. When using cron this might not be available.
@santosh0782: You seem to have missed the important part of my previous reply:
BTW: (ksh) today isn't a internal command. I'm guessing that today is a self written (ksh?) script. Be careful when using this. When using cron this might not be available.
yes. today is a self written script
Code:
#!/bin/ksh
TT=$1
k=`date +%d%m%y`$TT
export k
echo "$k"
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.