Copy IQ-Samples

Can someone guide me how to copy the IQ-samples via scp to another computer after reception completed.
How can I create a script which copies the data like “scp iq-file pi@ip-address:/path…”?

The ssh authorization is not the problem but how to to setup a script.

Alex

I am interested too.

It looks like you can provide the satnogs-client with a post observation script through the SATNOGS_POST_OBSERVATION_SCRIPT environment variable (or set it through satnogs-setup). It’s not clear if file name information based on the observation ID is available, but otherwise you could rename it in your observation script and rsync the iq.dat file over to another computer.

I did some testing but run into the problem that the script is executed as the user satnogs, which is not a general user login, so you can not set ssh authorization.

Someone may know away around it. Otherwise you could move the IQ file to the user (pi) home directory and have a cron job that syncs it to another machine.

Note though that the observation ID and start time are available in the observer.py script that runs the post observation script. My only worry is that if the IQ file has the generic name iq.dat that it will be overwritten if a new decoder/demodulator starts before the post observation script is executed.

@cgbsat
Thank’s for testing and your help with the ssh issue.
Now I’am using rsync.

I try this script, which works well if I use i.e.:

ZEIT="20180508130000"

but not with:

ZEIT=$(date "+%Y%m%d%H%M%S")

The variable $ZEIT is garbled, it contains:

linux; GNU C++ version 6.2.0 20161010; Boost_106100; UHD_003.009.005-0-unknown
                          2018050905130501

instead of the time.

Can somebody help me with this?

Alex

Script:

+++++++++++++++++++++++++++++
#!/bin/bash

cd /tmp || exit

#ZEIT=$(date "+%Y%m%d%H%M%S")
ZEIT="2018050813000000"
mv -v iq.dat ${ZEIT}.dat >>log.txt 2>&1
/usr/bin/rsync -v --password-file=/etc/satnogs.secret ${ZEIT}.dat 192.168.178.3::IQ >>log.txt 2>&1
rm -v ${ZEIT}.dat >>log.txt 2>&1

logger "#### post.sh ${ZEIT}.dat finished. $UID ####"
echo "#####################" >>log.txt
exit 0
######################

I think you want to use backquotes in bash:

ZEIT=`date "+%Y%m%d%H%M%S"`

Yes, I have tried backquotes before with the same result.
Aren’t backquotes and $() the same in bash?

BTW: The problem doesn’t appear when I invoke the script as root with sudo -u satnogs -g satnogs post.sh, only when invoked as POST_OBSERVATION_SCRIPT.

as a workaround, may be you can try:
date “+%Y%m%d%H%M%S.dat” | xargs mv -v iq.dat

or may be escape the back-quote with anti-slash because there seems to be some
early evaluation of back-quotes somewhere, but it would be better to understand.

I will try a dive into sources…

Do you mean like this?

#!/bin/bash

cd /tmp || exit

FILE=`date +%Y%m%d%H%M%S.dat|xargs echo`

echo -n "FILE: " >>log.txt 
echo $FILE >>log.txt

mv -v iq.dat ${FILE} >>log.txt 2>&1

/usr/bin/rsync -v --password-file=/etc/satnogs.secret ${FILE} 192.168.178.5::IQ >>log.txt 2>&1

rm -v ${FILE} >>log.txt 2>&1

logger "#### post.sh ${FILE} finished. $UID ####"
echo "#####################" >>log.txt

exit 0

no, you replace your mv command by mine and you delete FILE setting.
backquotes are not needed anymore and our problem disappear.

Oh I see, but how can rsync the file and delete it after rsync is done, when I don’t have it’s name?

OK, we could continue using a file containing the filename, but it is better to understand why we are stuck.

The logger command in my post.sh gives the following output in /var/log/messages.log:
Are these debug messages of the boost library which are prefixed to the date?

#### post.sh linux; GNU C++ version 6.2.0 20161010; Boost_106100; UHD_003.009.005-0-unknown#012#012linux; GNU C++ version 6.2.0 20161010; Boost_106100; UHD_003.009.005-0-unknown#012#012linux; GNU C++ version 6.2.0 20161010; Boost_106100; UHD_003.009.005-0-unknown 20180509143512.dat finished. 999 ####

Don’t you have somewhere (.bashrc .bash_login, any profile file in home dir or in /etc/profile*)
a command “uname” which seems to be evaluated when bash starts a subshell (with $() or backquotes).

BTW: check with the bash man page but what you may want to do is 2>&1 >> log.txt
(which is counter intuitive)

It appears the linux; GNU C++ version 6.2.0 20161010; Boost_106100; UHD_003.009.005-0-unknown precedes any command that’s being run. You could try something like date +%FT%T | tail -n1 to get the last line.

I was wrong, it is not in profiles, it seems to be linked with gnuradio.

If I use in the POST_OBSERVATION_SCRIPT:

echo "Hello world"|tail -n1 >>test.log

test.log contains:

linux; GNU C++ version 6.2.0 20161010; Boost_106100; UHD_003.009.005-0-unknown

Hello world

It seems “tail” remove the “bad” lines and introduces them by itself then.

how do you specify your script to POST_OBSERVATION_SCRIPT?

I have tried a very similar script, I do not run into your problems
(I have a very different config however).

I run into another problem, I do not see any iq.dat file.

SATNOGS_POST_OBSERVATION_SCRIPT: /usr/local/bin/post.sh

ENABLE_IQ_DUMP is enabled and
IQ_DUMP_FILENAME is empty.