bash script for seismic date - bash

I have the following command and the original work 100 %,
the original
suchw key1=gstat key3=gelev c=-1 b=-0.00245187 key2=gy a=11803.7 d=3.2 < cmp.su > cmp_geophon_statik.su &
#suchw key1=sstat key3=selev c=-1 b=-0.00245187 key2=sy a=11803.7 d=3.2 < cmp_geophon_statik.su > cmp_statik.su &
#sustatic hdrs=1 sign=1 < cmp_statik.su > cmp_mit_statik.su &
#cat cmp_mit_statik.su | suwind key=ep min=1195 max=1197 | supsimage perc=95 title='der siemogram nach staitch' > evince www.pdf &
not: with last commend I tried to export the result to pdf file but it look like not work exactly just i would
but i wanted to write it like bash script(like 'trt.su') and i wrot them so,
#!/bin/bash
cat cmp.su \
| suchw key1=gstat key3=gelev c=-1 b=-0.00211187t key2=gy a=11803.7 d=3.2 \
| > cmp_geophon_statik.su &&
exit
#cat cmp_geophon_statik.su \
#| suchw key1=sstat key3=selev c=-1 b=$geschwindigkeit key2=sy a=11803.7 d=3.2 \
#| >> cmp_statik.su
#exit
#cat cmp_statik.su \
#| sustatic hdrs=1 sign=1 \
#| >> cmp_mit_statik.su
#exit
cat cmp_mit_statik.su | suwind key=ep min=913 max=913 | suxwigb clip=10
but they didn't worked.
can you help me?

Related

Set csh prompt to raw output of a command with multiple lines and special characters?

I am trying to set my csh prompt to the raw output of a particular command. I know how to do that for simple outputs; for example:
set prompt=`echo propmt%|sed "s/pm/mp/"`
... results in a prompt of:
prompt%
But the prompt I want is more complex. First, it has multiple lines. I know how to do that directly (i.e. not via the output of a command):
set prompt="This is a line\nThis is another\nAnd this is the last% "
... results in:
This is a line
This is another
And this is the last%
But if I try to do that same thing through a command:
set prompt=`echo "This is a line\
This is another\
And this is the last% "`
... the prompt becomes just:
This
... not even This is a line; just This.
On top of that, the specific command that I want to use will output not just multiple lines, but also a bunch of other characters that I assume csh and/or set will interpret in ways that I don't intend. Specifically:
cowsay -f ghostbusters "BOOOOOOOOOOOOOOOOOOOOOOOOO \
? \
? You are using CEEEEEE SHELLLLLLLLLLLLLLLLL\
? \
? Be my guest, but you have no one to blame but\
? YOURSELLLLLLLLLLLLLLLLLLLLLLF"; echo; echo "% "
... which outputs:
_________________________________________
/ BOOOOOOOOOOOOOOOOOOOOOOOOO \
| |
| You are using CEEEEEE |
| SHELLLLLLLLLLLLLLLLL |
| |
| Be my guest, but you have no one to |
\ blame but YOURSELLLLLLLLLLLLLLLLLLLLLLF /
-----------------------------------------
\
\
\ __---__
_- /--______
__--( / \ )XXXXXXXXXXX\v.
.-XXX( O O )XXXXXXXXXXXXXXX-
/XXX( U ) XXXXXXX\
/XXXXX( )--_ XXXXXXXXXXX\
/XXXXX/ ( O ) XXXXXX \XXXXX\
XXXXX/ / XXXXXX \__ \XXXXX
XXXXXX__/ XXXXXX \__---->
---___ XXX__/ XXXXXX \__ /
\- --__/ ___/\ XXXXXX / ___--/=
\-\ ___/ XXXXXX '--- XXXXXX
\-\/XXX\ XXXXXX /XXXXX
\XXXXXXXXX \ /XXXXX/
\XXXXXX > _/XXXXX/
\XXXXX--__/ __-- XXXX/
-XXXXXXXX--------------- XXXXXX-
\XXXXXXXXXXXXXXXXXXXXXXXXXX/
""VXXXXXXXXXXXXXXXXXXV""
%
That's what I want as my csh prompt. At this point, I feel obligated to note that I am not kidding.
I suppose I could forget about running a command to generate it, and instead just manually converting it to a single-line string that's properly escaped for set prompt, but:
That seems like a pain;
I'd like to be able to quickly and easily change the prompt to similar but different things.
So, I'm hoping for some way to tell set prompt "Just use the raw output of (arbitrary-command); don't interpret any of it as special characters or whatever". Is there a way? Or any alternate suggestions to accomplish what I want? Thanks.
Maybe it's better to use the precmd alias for this:
alias precmd 'cowsay -f ghostbusters << EOF \
line 1 \
\
line 2 \
\
line 3 \
EOF'
From csh(1):
precmd Runs just before each prompt is printed. For example, if one
does
> alias precmd date
then date(1) runs just before the shell prompts for each command.
There are no limits on what precmd can be set to do, but
discretion should be used.
Or you can make it a different file to avoid all the backslashes:
alias precmd 'source ~/cowsay'
# ~/cowsay
cowsay -f ghostbusters << EOF
line 1
line 2
line 3
EOF

GhostScript auto pagenumbering

I want to export one certain page from a pdf document to an image and automatically fill the page number in the file name. When I run the following code:
gs \
-sDEVICE=jpeg \
-o outfile-%03.jpeg \
-dFirstPage=12 \
-dLastPage=12 \
wo.pdf
I get: outfile-001.jpeg instead of outfile-012.jpeg.
I've wrote a bash script for the job:
function extract_nth_page(){
printf -v j "outfile-%05g.png" $1
echo $j
gs -q -dNOPAUSE -sDEVICE=png16m -r600 -dFirstPage=$1 -dLastPage=$1 -sOutputFile=$j $2 -c quit
return 0
}
# Extracts page number 42 from myFile.pdf to outfile-00042.png
extract_nth_page 42 myFile.pdf

How to run a script with correct permissions from custom udev rule?

I set up a custom udev rule triggered when my bluetooth mouse connects:
ACTION=="add" \
, ATTRS{idProduct}=="XXX" \
, ATTRS{idVendor}=="XXX" \
, ENV{DISPLAY}=":0" \
, ENV{XAUTHORITY}="/run/user/1000/gdm/Xauthority" \
, RUN+="/home/XXX/.scripts/mouse_connected.sh"
udevadm test succeeds, everything seems fine.
Then i created my script that should be triggered:
#!/bin/bash
if (xinput list | grep Maus | grep -o id=[0-9]* | grep -o [0-9]*$);
then xinput set-button-map "$(xinput list | grep Maus | grep -o id=[0-9]* | grep -o [0-9]*$)" 1 1 3 && logger "success";
else logger "fail" && sleep 3;
fi
when I manually run the script in terminal using "bash '/home/XXX/.scripts/mouse_connected.sh'" it works as expected. But when it gets successfully triggered via my custom udev rule it fails. - But why?

Cron job - exported file emailed is blank

I am receiving the email from the following CRON job but with a blank file attached. I have checked the /home/XXXXXX/public_html/tmp/ directory and a good tqhsa_hikashop_order.txt file is created in that /tmp/ folder but the one attached to the email that I receive is empty.
mysql --database=XXXXXXXX_jml_6UCHadruwR8veju3 -u XXXXXXXX_8eh6Nu --password=fRa6r7wRerEtuzud -B -e "SELECT order_number, order_created, order_invoice_number, order_full_price, order_discount_code, order_discount_price, order_payment_method, order_payment_price FROM tqhsa_hikashop_order;" > /home/XXXXXXXX/public_html/tmp/tqhsa_hikashop_order.txt | mail -s "Daily Discount Table Dump" -a /home/XXXXXXXX/public_html/tmp/tqhsa_hikashop_order.txt luke#example.com
Any ideas why the good text file is not being attached?
You need to ensure that your first command finishes before running the second, so that the file exists on disk.
So essentially replace the | with a &&:
mysql \
--database=XXXXXXXX_jml_6UCHadruwR8veju3 \
-u XXXXXXXX_8eh6Nu \
--password=fRa6r7wRerEtuzud \
-B \
-e "SELECT order_number, order_created, order_invoice_number, order_full_price, order_discount_code, order_discount_price, order_payment_method, order_payment_price FROM tqhsa_hikashop_order;" > /home/XXXXXXXX/public_html/tmp/tqhsa_hikashop_order.txt \
&& \
mail \
-s "Daily Discount Table Dump" \
-a /home/XXXXXXXX/public_html/tmp/tqhsa_hikashop_order.txt luke#example.com
To illustrate using an example:
myuser#myshell:~ $ echo "testing" > testy.txt | cat testy.txt
cat: testy.txt: No such file or directory
myuser#myshell:~ $ echo "testing" > testy.txt && cat testy.txt
testing

issue with awk and variables from previous line

Code typically speaks better than thousand bytes. So did this demo code that does not obey my logic. Typically I trust compilers and programs, so I think I have a typo or something somewhere.
Please, could you point it out to me?
copy & paste code below into mydemo.sh file, and run it using command sh ./mydemo.sh
in my ref system this prints out:
mytux:~# ./mydemo.sh
This should spit out:
{USER1NAME} {Firstname Surname} {user1name}
{USER2NAME} {Secondname Surname} {user2name}
{USER3NAME} {Thirdname Surname} {user3name}
---- but it spits out:
{USER1NAME} {somestring: user1name}, {user1name}
{USER2NAME} {somestring: user2name}, {user2name}
{USER3NAME} {somestring: user3name}, {user3name}
----
Why so and how to fix it?
and here's the code:
#!/bin/sh
echo "# Firstname Surname, Company">usernames.txt
echo "somestring: user1name">>usernames.txt
echo "# Secondname Surname, Company">>usernames.txt
echo "somestring: user2name">>usernames.txt
echo "# Thirdname Surname, Company">>usernames.txt
echo "somestring: user3name">>usernames.txt
echo "This should spit out:"
echo "{USER1NAME} {Firstname Surname}, {user1name}"
echo "{USER2NAME} {Secondname Surname}, {user2name}"
echo "{USER3NAME} {Thirdname Surname}, {user3name}"
echo "---- but it spits out:"
echo "{USER1NAME} {somestring: user1name}, {user1name}"
echo "{USER2NAME} {somestring: user2name}, {user2name}"
echo "{USER3NAME} {somestring: user3name}, {user3name}"
echo "---- See:"
cat usernames.txt|awk \
'BEGIN { $mylink="";} \
{ \
if(match($0,"^#")!=0) \
{ \
split($0, a, ","); \
$mylink=$a[1]; \
} \
else \
{ \
if(length($mylink)>0) \
{ \
print "{" toupper($2) "} {" $mylink "}, {" $2 "}"; \
} \
$mylink=""; \
} \
}'
echo "----"
echo "Why so and how to fix it?"
Is this what you're trying to achieve? It would be easier to post the input text as is.
$ awk -F"[, ]" -v OFS="}, {" '
/^#/{n=$2" "$3;next}
{print "{" toupper($2), n, $2"}"}
' usernames.txt
{USER1NAME}, {Firstname Surname}, {user1name}
{USER2NAME}, {Secondname Surname}, {user2name}
{USER3NAME}, {Thirdname Surname}, {user3name}

Resources