AT+CMGL="ALL" command return only OK - sms

Manufacturer: huawei
Model: E3533
Revision: 22.318.27.00.00
IMEI: 353934033009021
+GCAP: +CGSM,+DS,+ES
AT+CMGS command work well.
OK
AT+CMGS="99667788"
> test sms
+CMGS: 45
OK
AT+CMGL="ALL"
OK
AT+CPMS="SM"
+CPMS: 0,40,0,40,0,40
OK
AT+CPMS=?
+CPMS: ("SM","ME"),("SM","ME"),("SM","ME")
OK
AT+CMGL="ALL"
OK

Most common reason for returning OK would be that there are no messages stored in memory.
To check if that's the case run the reading command without setting the Preferred Storage.

Related

Can't upload file via FTP on Golang

I'm currently using github.com/jlaffaye/ftp on Go to send files.
I'm trying to connect to an FTP and upload a zipped file of about 700MB.
I connect to server properly and change the working dir but when I'm about to call the Stor function, it responds with "connection refused" and drops.
This is the code:
ftpFile="hola.txt"
fileOpen, err := os.Open(ftpFile) // For read access.
if err != nil {
fmt.Println("error "+ftpFile)
panic(err)
} else {
fmt.Println("abierto "+ftpFile)
}
reader:=bufio.NewReader(fileOpen)
err = client.Stor(ftpDir+ftpFile,reader)
if err != nil {
fmt.Println("error en stor "+ftpDir+ftpFile)
panic(err)
} else {
fmt.Println("subiendo "+ftpFile)
}
defer fileOpen.Close()
I'm opening a file with os.Open then read it with bufio.NewReader and pass it to the Stor function but it disconnects. The FTP is good as I was connected to it via FileZilla, the zipfile or txt file (in this code example) are both good and I believe I'm missing the shot when it comes to the bufio.NewReader but I can't find a working example of reading a file and using this goftp library.
Update:
Here's the logfile
220 Microsoft FTP Service
USER *user goes here*
331 Password required
PASS *plain text password goes here*
230 User logged in.
FEAT
211-Extended features supported:
LANG EN*
UTF8
AUTH TLS;TLS-C;SSL;TLS-P;
PBSZ
PROT C;P;
CCC
HOST
SIZE
MDTM
REST STREAM
211 END
TYPE I
200 Type set to I.
OPTS UTF8 ON
200 OPTS UTF8 command successful - UTF8 encoding now ON.
CWD /web-import/pre/
250 CWD command successful.
PWD
257 "/web-import/pre" is current directory.
PASV
227 Entering Passive Mode (x,x,x,x,x,x).
Update: Looks like someone had the same problem some weeks ago: goftp - 229 Entering Extended Passive Mode now I'll be looking for solutions and will post here.
Update: Changed the script to connect to a CentOS server and got the same error. Now that the FTP server is discarded then there are 2 culprits: goftp package and the script itself.
Update: Tried again with a simpler script following example at documentation and failed again at the same spot. Had to report issue on developer's Github https://github.com/jlaffaye/ftp/issues/272
Update: I connected via terminal and opened FTP from command line. I typed "ls" by mistake and got this error
227 Entering Passive Mode (x,x,x,x,x,x).
ftp: connect: Connection refused
Last Update: After coding and debugging in the end it wasn't the goftp package neither the server neither the client. It was my firewall that blocked my ftp from going PASV. I whitelisted the ip and it worked perfectly.

Bash How to kill wget process after a given timeout? [duplicate]

This question already has answers here:
Timeout command on Mac OS X?
(6 answers)
Closed 1 year ago.
UPDATE:
This question has been closed. I asked in another question.
Bash how to run multiple wget with output by sequence (NOT Parallel) and delete the wget file for speedtest purpose
I used timeout solution
#!/bin/bash
function speedtest() {
local key=$1
local url=$2
timeout 10 wget $url
echo -e "\033[40;32;1m$key is completed.\033[0m"
}
speedtest "Lisbon" "https://lg-lis.fdcservers.net/100MBtest.zip"
speedtest "London" "https://lg-lon.fdcservers.net/100MBtest.zip"
speedtest "Madrid" "https://lg-mad.fdcservers.net/100MBtest.zip"
speedtest "Paris" "https://lg-par2.fdcservers.net/100MBtest.zip"
When I run the bash script, this is the output.
» ./wget_speedtest.sh [2021/05/8 |15:42:49]
Redirecting output to ‘wget-log’.
Lisbon is completed.
Redirecting output to ‘wget-log.1’.
London is completed.
Redirecting output to ‘wget-log.2’.
Madrid is completed.
Redirecting output to ‘wget-log.3’.
Paris is completed.
I am expected to see the kb/s for running after 10 seconds for each wget.
I have a list of wget of file to download and want to see the download speed. I just want to run about 10 seconds, then print out the result what is the download speed.
I have 20 different server file to test out. My goal is to see the how kb/s download for that 10 seconds.
e.g
> wget https://lg-lis.fdcservers.net/100MBtest.zip
--2021-05-08 13:37:37-- https://lg-lis.fdcservers.net/100MBtest.zip
Resolving lg-lis.fdcservers.net (lg-lis.fdcservers.net)... 50.7.43.4
Connecting to lg-lis.fdcservers.net (lg-lis.fdcservers.net)|50.7.43.4|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 104857600 (100M) [application/zip]
Saving to: ‘100MBtest.zip’
100MBtest.zip 0%[ ] 679.66K 174KB/s eta 9m 26s ^C
This is my bash file
#!/bin/bash
function speedtest() {
local key=$1
local url=$2
( cmdpid=$$;
(sleep 10; kill $cmdpid; rm -f 100M) \
& while ! wget "$url"
do
echo -e "\033[40;32;1m$key for 10 seconds done.\033[0m"
done )
}
speedtest "Lisbon" "https://lg-lis.fdcservers.net/100MBtest.zip"
speedtest "London" "https://lg-lon.fdcservers.net/100MBtest.zip"
speedtest "Madrid" "https://lg-mad.fdcservers.net/100MBtest.zip"
speedtest "Paris" "https://lg-par2.fdcservers.net/100MBtest.zip"
However, the above code does not work, it still download at background and redirect to wget-log
> ./wget_speedtest.sh
--2021-05-08 13:41:56-- https://lg-lis.fdcservers.net/100MBtest.zip
Resolving lg-lis.fdcservers.net (lg-lis.fdcservers.net)... 50.7.43.4
Connecting to lg-lis.fdcservers.net (lg-lis.fdcservers.net)|50.7.43.4|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 104857600 (100M) [application/octet-stream]
Saving to: ‘100M’
100M 5%[==> ] 5.84M 1.02MB/s eta 79s [1] 21251 terminated ./wget_speedtest.sh
Redirecting output to ‘wget-log’.
Use the timeout command (part of GNU coreutils):
$ timeout 10 wget https://lg-lis.fdcservers.net
/100MBtest.zip
--2021-05-07 22:53:20-- https://lg-lis.fdcservers.net/100MBtest.zip
Resolving lg-lis.fdcservers.net (lg-lis.fdcservers.net)... 50.7.43.4
Connecting to lg-lis.fdcservers.net (lg-lis.fdcservers.net)|50.7.43.4|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 104857600 (100M) [application/zip]
Saving to: ‘100MBtest.zip’
100MBtest.zip 0%[ ] 23.66K 10.8KB/s
$
If the specified time is exceeded, timeout exits with a status of 124.
timeout --help or info coreutils timeout for more information.
If you're on MacOS, see Timeout command on Mac OS X? for some suggested alternatives.

FTP Client Output Response standard

After successful FTP file transfer, the the response is used to be "226 File send OK", but suddenly, it has changed to be "226 Transfer complete"
I have below questions:
Does FTP response code has any standard?
Can we customize FTP output response for a specific status code?
Find the standard FTP response for file transfer
$ ftp canopus
Connected to canopus.austin.century.com.
220 canopus.austin.century.com FTP server (Version 4.1 Sat Nov 23 12:52:09 CST 1991) ready.
Name (canopus:eric): dee
331 Password required for dee.
Password:
230 User dee logged in.
ftp> pwd
257 "/home/dee" is current directory.
ftp> cd desktop
250 CWD command successful.
ftp> type ascii
200 Type set to A.
ftp> send typescript
200 PORT command successful.
150 Opening data connection for typescript (128.114.4.99,1412).
226 File send OK.
ftp> cdup
250 CWD command successful.
ftp> bye
221 Goodbye.
Note: suddenly the response text 226 File send OK has changed to 226 Transfer complete
Find the details about FTP responses on wikipedia
RFC 959, 4.2. FTP REPLIES:
An FTP reply consists of a three digit number (transmitted as
three alphanumeric characters) followed by some text. The number
is intended for use by automata to determine what state to enter
next; the text is intended for the human user. It is intended
that the three digits contain enough encoded information that the
user-process (the User-PI) will not need to examine the text and
may either discard it or pass it on to the user, as appropriate.
In particular, the text may be server-dependent, so there are
likely to be varying texts for each reply code.

Reboot if web service (tomcat7) is not responding

I am running a web app on a Tomcat server. There is a hard-to-detect problem within the server code that causes it to crash once or twice everyday. I will dig in to correct it when I have time. But until that day, in a problematic case restarting tomcat (/etc/init.d/tomcat7 restart) or basically rebooting the machine also seem pretty good solutions for now. I want to detect liveliness of server with wget instead of grep or something else because even though tomcat is running my service may be down.
wget localhost:8080/MyService/
outputs
--2012-12-04 14:10:20-- http://localhost:8080/MyService/
Resolving localhost... 127.0.0.1
Connecting to localhost|127.0.0.1|:8080... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2777 (2.7K) [text/html]
Saving to: “index.html.3”
100%[======================================>] 2,777 --.-K/s in 0s
2012-12-04 14:10:20 (223 MB/s) - “index.html.3” saved [2777/2777]
when my service is up. And outputs
Resolving localhost... 127.0.0.1
Connecting to localhost|127.0.0.1|:8080... failed: Connection refused.
or just stucks after saying
--2012-12-04 14:07:34-- http://localhost:8080/MyService/
Resolving localhost... 127.0.0.1
Connecting to localhost|127.0.0.1|:8080... connected.
HTTP request sent, awaiting response...
otherwise. Can you offer me a shell script with a cron job or something else to do that. I prefer not to use cron if there is an alternative.
Why not using cron for that? Anyway ig oogled for tomcat + watchdog and found the following blog post.
Should give you and idea how to solve your problem.
hth
OK I find the solution to add a script under /etc/rc5.d/ as told here http://www.linuxforums.org/forum/mandriva-linux/27687-how-make-command-run-startup.html
!/bin/bash
echo "Restarted: " `date` >> /home/ec2-user/reboot.log
sleep 600
while [ 1 ]
do
var=`php -f /home/ec2-user/lastEntry.php`
if [ ${#var} -gt 3 ]
then
echo "Restarting: " `date` >> /home/ec2-user/reboot.log
reboot
fi
sleep 60
done
where last query checks a table to see if is there any entry in last 10 mins.
<?php
mysql_connect('ip', 'uname', 'pass') or die(mysql_error());
mysql_select_db("db") or die(mysql_error());
$query="SELECT min(now()-time) as last FROM table;";
$result = mysql_query($query)or die(mysql_error());
$row = mysql_fetch_array($result);
echo $row['last'];
?>
There are more straightforward ways to check if tomcat is running but this checks on the last output so more accurate check it's.

pppd stuck in dialing process

i'm connecting several usb modems to my Ubuntu:
uname -a
Linux devlp 2.6.32-28-generic #55-Ubuntu SMP Mon Jan 10 21:21:01 UTC 2011 i686 GNU/Linux
pppd version: 2.4.5
i'm doing a test with 8 sierra wireless modems, and all of them are connected and work. each of them has a "ppp" interface.
after they are connected, i'm trying to reconnect ppp7, and at first, pppd fails, then in the second try it reaches the point where it says: "Serial connection established" and stuck. i tried all kill signals to kill that pppd without success, and the only way to terminate it is to plug-out the modem it tried to dial.
i looked for the exact place where the pppd get stuck and it's right over here:
int generic_establish_ppp (int fd)
{
int x;
if (new_style_driver) {
int flags;
FILE *f=fopen("/root/ptest.log","a");
fputs("before get channel\n",f);
fflush(f);
/* Open an instance of /dev/ppp and connect the channel to it */
if (ioctl(fd, PPPIOCGCHAN, &chindex) == -1) { // <<<<<<< STUCK HERE
error("Couldn't get channel number: %m");
goto err;
}
fputs("after get channel\n",f);
....
}
}
it looks like the problem is specifically with ppp7 - and it can be any modem so i don't think it's a modem problem, but what i don't understand is what really happens in that command? who is responsible for the answer? is it only the kernel? the modem driver? the modem itself? i don't quite understand what to do with that information since PPPIOCGCHAN documentation is very poor..
i thought at first that maybe pppd is not releasing the channel or ppp after disconnect so i compiled my own pppd version and added PPPIOCDISCONN and PPPIOCDETACH just to make sure my version is fine with that, and the results were the same.
what you think?
well i'm pretty i solved this one - I've added some lines in pppd before the ioctl command to make fd NONBLOCK :)

Resources