January 12, 2017, 9:32 am
Hi All,
I have created a unix script to mail the xls file.This is being done using mailx command
Code:
fdate=`tail -1 abc.xls | cut -c1-8`
SUBJECT="CARD GL Exceptions : ${ENV} for ${fdate}"
destname=CARD_GL_Exceptions_$fdate
sed 's/#BUSINESS/BUSINESS/1' abc.xls > abc2.xls
mv abc2.xls abc.xls
line_count=`wc -l abc.xls|awk '{print $1}'`
echo $line_count
if [ $line_count -gt 1 ]
then
(echo "Hi,
Please find attached.
Regards";uuencode abc.xls $destname.xls) | /usr/bin/mailx -s "${SUBJECT}" ${TO} ${CC}
Everything is working fine except the fact that am getting an error messgae every time i open the file
Error Message : "The file you are trying to open is in a different format than specified by the file extension.Verify that file is not corrupted and is from a trusted source.Doyou want to open the file"
I have to click on yes every time .I need to get rid of this error message.Kindly help.
Regards,
Karthik
↧
January 12, 2017, 9:45 am
Hi -
I have below in put to demo.txt
Code:
/test/xyz/ibcdownload.jsp
/test/xyz/pvxprogramtreeovermain.jsp
/test/xyz/jtfrsrsr$HtmlTag.jsp
/test/xyz/csdronumlov.jsp
/test/xyz/iecvaluereset.jsp
/test/xyz/ibecumpassignrole.jsp
/test/xyz/ozfoffermarketmain.jsp
output should be
/test/xyz/ibcdownload.jsp
/test/xyz/pvxprogramtreeovermain.jsp
/test/xyz/jtfrsrsr.jsp
/test/xyz/csdronumlov.jsp
/test/xyz/iecvaluereset.jsp
/test/xyz/ibecumpassignrole.jsp
/test/xyz/ozfoffermarketmain.jsp
I am trying
HTML Code:
sed "s/\$\*\./\./g"
is not working for me.
either all character and lines are replaced or it says pattern doesnt match.
I tried online but was not able to get it working.
Appreciate any help..
Thanks,
↧
↧
January 12, 2017, 1:32 pm
I have 10 scripts which use awk/nawk extensively.
I have to always change awk to nawk and nawk to awk when i deploy all my scripts to different types of servers as some support nawk while other support awk.
Can you propose a solution that without having to tweak my 10 scripts at several places everytime i deploy them to a new set of servers the awk-nawk problem should be automatically addressed.
Note: I cannot change my user .profile as it is used by other users as well.
↧
January 12, 2017, 9:39 pm
My requirement is to find out data in any of the file in particular path.
I am using UNIX OS.
For example I have two files. A123.rej & A345.rej
A123.rej contain data
A345.rej is a empty file.
I tried a code to find , if any of this file contains data, I need to echo as data found, if both the files are empty, then I will echo as No data. Currently I am using the below code.But its not working.Kindly help on this
Code:
if [ -s A*.rej ]
then echo "Data"
else
echo "No data"
fi
↧
January 13, 2017, 4:48 am
Hi.
I need to append/prefix an & character to every 'single' & character (not when there are 2 or more grouped together) I find in a file. I can do it using this cmd:
Code:
cat ${file} | sed -e 's/&/&&/g' > ${new_file}
How can I modify this to ensure I only replace single &'s and not operate on multiple groupings like && or &&& etc.?
Many thanks.
↧
↧
January 13, 2017, 5:38 am
Hi all,
Does anyone know how to convert a good few files in a particular directory (unix) to dos files and place them in another directory?
I know this can be done with ux2dos but I am trying to come up with a shell script to do so
↧
January 13, 2017, 5:51 am
Hi All,
I am using a informatica job to create a csv file and a unix script the mail the generated file.Everything is working fine but I am not seeing leading zeros in the csv file sent in the mail.These zeros were present when the .csv file was generated by informatica procees.
Is there any command which I can use in shelll script which will dfisplay that?Please help
Code:
fdate=`tail -1 abc.csv | cut -c1-8`
SUBJECT="execp : ${ENV} for ${fdate}"
destname=file_$fdate
sed 's/#BUSINESS/BUSINESS/1' abc.csv > abc2.csv
mv abc2.csv abc.csv
line_count=`wc -l abc.csv|awk '{print $1}'`
echo $line_count
if [ $line_count -gt 1 ]
then
(echo "Hi,Team";uuencode abc.csv $destname.csv) | /usr/bin/mailx -s "${SUBJECT}" ${TO} ${CC}
↧
January 13, 2017, 7:47 am
Dear All,
Saying, I have two distinct functions with the same goal (counting lines containing a specific pattern in a file
MyFile).
To perform that operation, I used a "while loop" with two different syntax ("grep" command would be much more better in that case but this is not the concern in our case) !:
(1) cat MyFile | while read -r line;do; ... ;done;
(2) while read -r line; do; ...;done < MyFile;
Inside the while loop, I used a variable
var to store the result.
My questions:
(1) is that the expected behaviour to not be able to get the value of var outside the while for the first syntax ?
(2) what kind of system's difference between both syntax ?
Thanks a lot for your attention, :)
cf. examples below:
Code:
[x004191a@xsnl11p317a log]$ echo $SHELL
/bin/bash
[x004191a@xsnl11p317a log]$ fnct_dae_V1 ()
> {
>
> var=0
>
> cat "STG_INSTNCE_COMPLTED_01_451_20170112193018.log" | while read -r line
> do
>
> if [[ $(echo "$line" | grep -i 'completed') ]]
> then
>
> ((var++))
>
> echo "- INSIDE WHILE:var:$var"
>
> fi
>
> done
>
> echo "- OUTSIDE WHILE:var:$var"
>
> }
[x004191a@xsnl11p317a log]$ fnct_dae_V1
- INSIDE WHILE:var:1
- INSIDE WHILE:var:2
- INSIDE WHILE:var:3
- INSIDE WHILE:var:4
- OUTSIDE WHILE:var:0
[x004191a@xsnl11p317a log]$
[x004191a@xsnl11p317a log]$
[x004191a@xsnl11p317a log]$
[x004191a@xsnl11p317a log]$
[x004191a@xsnl11p317a log]$ fnct_dae_V2 ()
> {
>
> var=0
>
> while read -r line
>
> do
>
> if [[ $(echo "$line" | grep -i 'completed') ]]
> then
>
> ((var++))
>
> echo "- INSIDE WHILE:var:$var"
>
> fi
>
> done < STG_INSTNCE_COMPLTED_01_451_20170112193018.log
>
> echo "- OUTSIDE WHILE:var:$var"
>
> }
[x004191a@xsnl11p317a log]$ fnct_dae_V2
- INSIDE WHILE:var:1
- INSIDE WHILE:var:2
- INSIDE WHILE:var:3
- INSIDE WHILE:var:4
- OUTSIDE WHILE:var:4
[x004191a@xsnl11p317a log]$
↧
January 13, 2017, 9:09 am
Hi Guys,
i world like to do the following with awk,
i have the the complete username
example in a file a have some names
Code:
Mario Rossi
John Doe
i would like to convert this name in this format from file with awk
Code:
Mario,Rossi,"Mario Rossi [External]",m.rossi_ext@mydomain.com,$TRUE,
John,Doe,"John Doe [External]",j.doe_ext@mydomain.com,$TRUE,
Is it possible?
Thanks.
Moderator's Comments:
|
|
Please use CODE tags as required by forum rules!
|
|
↧
↧
January 13, 2017, 9:14 am
It is crazy when you just entered a command example sudo or su or even ps. It will flood your /var/log/messages. Please see duplicate entries except for the pid. At 1 specific time.
Thanks
Code:
[user1@SERVER1:~]$ cat b
Jan 13 17:09:05 SERVER1 bash[727]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[731]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[735]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[739]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[745]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[749]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[753]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[757]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[761]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[765]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[769]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[773]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[783]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[787]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[791]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[795]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[801]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[805]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[809]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[813]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[823]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[827]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[831]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[835]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[841]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[845]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[849]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[854]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[858]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[862]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[866]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[870]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[874]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[884]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[888]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[892]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[896]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[900]: user1 as root:
Jan 13 17:09:05 SERVER1 bash[904]: user1 as root:
[user1@SERVER1:~]$
Moderator's Comments:
|
|
Please use CODE tags as required by forum rules!
|
|
↧
January 13, 2017, 3:32 pm
The below
awk will filter a list of
30,000 lines in the
tab-delimited file. What I am having trouble with is adding a condition to
SVTYPE=CNV
that will only print that line if
CI= must be
>.05 .
The other condition to add is if
SVTYPE=Fusion, then in order to print that line
READ_COUNT must be
> 10. Thank you :).
file
Code:
chr1 11184539 MTOR A <CNV> 100.0 PASS FR=.;PRECISE=FALSE;SVTYPE=CNV;END=11217311;LEN=32772;NUMTILES=4;SD=0.18;CDF_MAPD=0.01:1.373797,0.025:1.472018,0.05:1.562112,0.1:1.67288,0.2:1.817619,0.25:1.875834,0.5:2.13,0.75:2.418604,0.8:2.496068,0.9:2.71203,0.95:2.904337,0.975:3.082096,0.99:3.302454;REF_CN=2;CI=0.05:1.56211,0.95:2.90434;RAW_CN=2.13;FUNC=[{'gene':'MTOR'}] GT:GQ:CN ./.:0:2.13
chr1 11810242 AGTRAP-BRAF.A5B8.COSF828.1_1 G G]chr7:140494267] . FAIL SVTYPE=Fusion;READ_COUNT=0;GENE_NAME=AGTRAP;EXON_NUM=5;RPM=0.0000;NORM_COUNT=0.0;ANNOTATION=COSF828;FAIL_REASON=READ_COUNT<=40|NORM_COUNT<=0.0;FUNC=[{'gene':'AGTRAP','exon':'5'}] GT:GQ ./.:.
chr7:140494267] . PASS SVTYPE=Fusion;READ_COUNT=16;GENE_NAME=AGTRAP;EXON_NUM=5;RPM=0.0000;NORM_COUNT=0.0;ANNOTATION=COSF828;FAIL_REASON=|NORM_COUNT<=0.0;FUNC=[{'gene':'AGTRAP','exon':'5'}] GT:GQ ./.:.
desired output
Code:
chr7:140494267] . PASS SVTYPE=Fusion;READ_COUNT=16;GENE_NAME=AGTRAP;EXON_NUM=5;RPM=0.0000;NORM_COUNT=0.0;ANNOTATION=COSF828;FAIL_REASON=|NORM_COUNT<=0.0;FUNC=[{'gene':'AGTRAP','exon':'5'}] GT:GQ ./.:.
awk
Code:
awk -F'\t' -v OFS='\t\ '/SVTYPE=/{print}' file
↧
January 14, 2017, 12:10 am
To Solaris 8 Experts,
Please let me know what's the best method / procedure as well as the Solaris 8 commands for accomplishing the following tasks on a production Sun Enterprise 250 Server running Sun Solaris 8 Operating System:
1. Make an exact image/copy of the SCSI Hard Drive in the Sun E250 Server.
2. Use the image produced in step 1 above and copy it on to a new SCSI hard drive to be placed in a different Sun E250 Server to be used in the lab environment.
Please explain the step-by-step procedure and/or commands, and provide me with links to relevant potential documentation online (if available).
Thank you for your help.
↧
January 14, 2017, 2:04 am
I want to change my MAC at reboot, so making it a cron job like the following in BSD.
Can I do this in the jail for the user, setting it as a command or should it be a script?
I would set it as a command
Code:
openssl rand -hex 6 | sed 's/\(..)/\1:/g; s/.$//'
just to test it, it works.
Code:
@reboot usernamesomebody openssl rand -hex 6 | sed 's/\(..)/\1:/g; s/.$//'
I am asking this, because the BSD handbook tells me to try it first as a homebrew script in the really
special environment, that is giving me a headache like the following
Code:
env -i SHELL=/bin/sh PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin HOME=
And my second question is, would it be better to set it in the system crontab
or just user crontab?
So if someone can help me out, thanks in advance!!!
↧
↧
January 14, 2017, 9:05 am
I have a peculiar problem (aren't they all?). A new program that uses X11 fails to get any ButtonRelease event reported to it after the XNextEvent call. That is, mouse clicks don't work. The program gets others, such as exposure and keyboard events, but not button press or release. Other programs running on the same hardware obviously do get all mouse clicks. Compounding the problem, this failure occurs under Ubuntu and Mint, but all events are reported under Raspbian -- that is, under Raspbian the failure does not occur.
This is the setup instruction:
Code:
i = XSelectInput(dpy,win, ExposureMask | KeyPressMask |
ButtonReleaseMask | KeyReleaseMask);
After issuance
i contains 1.
I've read (seemingly relevant parts of) the X11 manual without gaining a clue. I'm hoping that someone else has experienced this problem and found the cause.
Would this question be more appropriate in another group? Which one?
--rLsj
Moderator's Comments:
|
|
Please use CODE tags when displaying sample input, sample output, and code segments.
|
|
↧
January 14, 2017, 4:20 pm
I have created a test
cronjob using
crontab -e that runs a script at
/home/cmccabe/cron.sh. I am not sure the script doesn't run though I can call it in terminal. Thank you :).
crontab -e (run script sat at 6:10pm)?
Code:
10 18 * * 6 /home/cmccabe/cron.sh
contents of cron.sh
Code:
#!/bin/bash
echo "Is it 6:10pm?"
I can see the service is running, but the cronjob does not execute.
↧
January 15, 2017, 6:45 am
Hi All,
I have recently installed Oracle Linux 6.7 server on Virtual box 5.1. The installation went smooth and i was able to create a VM on Windows 7 as host.The issue is that the default desktop that i see is not at the default resolution and i am only able to see half of the screen.
Initially i though it was related to Virtual box, but guest editions is properly installed and functions associated with guest additions such as shared drive and clipboard sharing are working as expected.
Other thing that i noticed was the missing Xorg.conf file. I tried to create a default one by giving the following command
but it gives the following error
Code:
Fatal server error:
Server is already active for display 0
Not sure where i might be going wrong. Request your expert help here.
THanks,
Dev
↧
January 15, 2017, 10:41 am
Please let me understand the meaning of following line in unix bash scripting .is =~ means not equal to or equal to .
Code:
if [[ $INFA_HOME =~ .*9.5.1.* ]]; then
echo -e "pmcmd startworkflow -sv ${INTSERV} -d ${INFA_DEFAULT_DOMAIN} -uv INFA_DEFAULT_DOMAIN_USER" \
"-pv INFA_DEFAULT_DOMAIN_PASSWORD -usdv INFA_DEFAULT_DOMAIN_SECURITY_DOMAIN" \
"-f ${FOLDER} -osprofile $OSPF -paramfile ${PARAM_FILE} -wait" \
"-rin ${INFA_RUN_ID} ${WORKFLOW};"
pmcmd startworkflow -sv ${INTSERV} -d ${INFA_DEFAULT_DOMAIN} -uv INFA_DEFAULT_DOMAIN_USER \
-pv INFA_DEFAULT_DOMAIN_PASSWORD -usdv INFA_DEFAULT_DOMAIN_SECURITY_DOMAIN \
-f ${FOLDER} -osprofile $OSPF -paramfile ${PARAM_FILE} -wait \
-rin ${INFA_RUN_ID} ${WORKFLOW};
export WF_RET_VAL=$?
else
↧
↧
January 15, 2017, 9:05 pm
Hi Team,
Please help me to resolve the error in my script
Code:
[root@selvahost ~]# echo $0
-bash
num=`wc -l /root/demp/hehe.txt`
[root@selvahost ~]# echo $num
6 /root/demp/hehe.txt
cat backtickwithif.sh
#! /bin/bash
num=`wc -l /root/demp/hehe.txt`
echo $num
#if [ $num -gt 150 ]
if [ "$num" -gt "150" ]
then
echo "Condition Success"
else
echo "Condition failed"
echo ; fi
./backtickwithif.sh
6 /root/demp/hehe.txt
./backtickwithif.sh: line 6: [: 6 /root/demp/hehe.txt: integer expression expected
Condition failed
If i use other condition in the script if [ $num -gt 150 ] then I get different error message
Code:
./backtickwithif.sh
6 /root/demp/hehe.txt
./backtickwithif.sh: line 5: [: too many arguments
Condition failed
↧
January 16, 2017, 12:12 am
Hi,
I have an issue where i need to lookup in a given transaction file and if the same transaction is found in another file, then i need to replace a few columns with some other value.
Finally, the changed and unchanged lines must be printed and stored in the same source file.
for example :
Code:
f2 (tran number is second field)
1,100,AAA,BBB,X,CCC
5,200,AAA,BBB,Y,CCC
3,400,AAA,BBB,X,CCC
output should be
Code:
1,100_P,AAA,BBB,X,CCC
5,200_T,AAA,BBB,Y,CCC
3,400,AAA,BBB,X,CCC
as you can see, only 1st and 2nd record have the matching tran from f1. hence they are changed, record 3 will remain as is.
I have done the following but its a very direct approach and takes a huge amount of time.
Code:
cp main_input.txt tmp1.txt;
while read tran_num
do
awk 'BEGIN{FS=","; OFS=","} { if ( $2=='${tran_num}' && $5 == "X") {$2=$2"_P";print} else if ($2=='${tran_num}' && $5 == "Y") {$2=$2"_T"; print} else {print} }' tmp1.txt > tmp2.txt;
cp tmp2.txt tmp1.txt;
done < lookup_tran_file.txt
mv tmp1.txt file_input_file.txt
the above works but i dont like the fact that the tmp file is created everytime to preserve the previous modification done by awk. In other words, if f1 will contain 10000 records to be checked, the tmp file will get overwritten 10000 times. This solution is also takin 1-2 hrs to finish depending on the input file size.
Moderator's Comments:
|
|
Please use CODE tags as required by forum rules!
|
|
↧
January 16, 2017, 1:47 am
Hi Gurus,
Is there a way to call a variable inside a function anywhere within the script?
Thanks.
BR,
Ernesto
↧