Author Topic: The 'service' in cli has changed on my system  (Read 1451 times)

Online wedgetail

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2428
  • Any Bugs in site?
The 'service' in cli has changed on my system
« on: February 03, 2011, 11:45:54 PM »
I am not sure when but the use of 'service' has changed on my system.

Some time back I could use this:

Code: [Select]
[root@localhost gert]# service mysqld status
[root@localhost gert]#            [  OK  ]

Now I get

Code: [Select]
[root@localhost gert]$ service mysqld status
/etc/init.d/mysqld: line 474: test: 11546: binary operator expected
[root@localhost gert]$

It seems to me there is a new player on the field:

Code: [Select]
[root@localhost gert]$ service mythbackend status
Cannot find mythbackend service
Usage: service -[Rfshv] SERVICE ARGUMENTS
        -f|--full-restart:      Do a fullrestart of the service.
        -R|--full-restart-all:  Do a fullrestart of all running services.
        -s|--status-all:        Print a status of all services.
        -d|--debug:             Launch with debug.
        -h|--help:              This help.
[root@localhost gert]$

Then I tried was to use the service -s which gave a long un-sorted list so I tried to grep it.

Code: [Select]
[root@localhost gert]$ service -s |grep sas
saslauthd (pid  2805) is running...
/etc/wlan/shared: line 71: [: too many arguments

[root@localhost gert]$ service -s |grep mysql
/etc/wlan/shared: line 71: [: too many arguments

[root@localhost gert]$ service -s >>/home/gert/junkmysql.glk
/etc/wlan/shared: line 71: [: too many arguments
[root@localhost gert]$

I am re-directing to a file to sort and study.   I am at a loss to what is going on here.

Any hints?
32 bit: KDE (older) & various KDE-mini, ASUSTek P5P41D Rev X.0x, BIOS AMI0207 07/21/2009, "Pentium(R) Dual-Core CPU E5300 @ 2.60GHz", nVidia GeForce 9600 GT, 2x1GB Seagate Technology 1000528AS HDD
TV CompuPro VideoMate Vista E700 (not working in Linux), Acer X243HD LCD Screen

Offline AS

  • Hero Member
  • *****
  • Posts: 4111
  • Have a nice ... night!
Re: The 'service' in cli has changed on my system
« Reply #1 on: February 04, 2011, 02:16:59 AM »
due to the fact that service is a shell script, you can try:

sh -x /sbin/service mysqld status

this will expand all executed commands, hopefully it will provide some hints about what is gong wrong.

AS

Online wedgetail

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2428
  • Any Bugs in site?
Re: The 'service' in cli has changed on my system
« Reply #2 on: February 04, 2011, 03:30:58 AM »
as
Thanks for replying. Something has changed here.  I restarted an instance of KDE with mythTV installed and muddled around with 'service' and the came back to the original KDE here and started testing. Unfortunately I was a bit careless and just copied your suggestion into cli.  

Code: [Select]
sh -x /sbin/service mysqld status
The answer was correct,  FAILED as I had not started 'mysqld' on boot up (don't really need it her as far as I know).   I started 'mysqld' from cli and now I also can use successfully:

Code: [Select]
[root@localhost gert]$ service mysqld status
[root@localhost gert]$                     [  OK  ]

Then I tried following and spotted the line 71 error, I will leave the full output and edit or remove it later if it is not really relevant.

Quote
[root@localhost gert]$ service -s
acpid (pid  781) is running...
Sound loaded
atd (pid  2108) is running...
atieventsd is stopped
Avahi daemon is running
bpalogin is stopped
crond (pid  2096) is running...
cupsd is stopped
dm (pid  1046) is running...
hald (pid 830) is running...
ibod is stopped
irqbalance is stopped
Laptop mode status:

Mounts:
   /dev/sda3 on / type ext4 (rw,commit=0)
   none on /proc type proc (rw)
   none on /dev/pts type devpts (rw)
   none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
 
Drive power status:
  
   /dev/sda:
    drive state is:  active/idle
  
   /dev/sdb:
    drive state is:  active/idle
  
   /dev/sdc:
    drive state is:  standby
  
   /dev/sdd:
    drive state is:  unknown
 
(NOTE: drive settings affected by Laptop Mode cannot be retrieved.)
 
Readahead states:
   /dev/sda3: 128 kB
 
Laptop Mode Tools is NOT allowed to run: /var/run/laptop-mode-tools/enabled does not exist.
 
/proc/sys/vm/laptop_mode:
   0
 
/proc/sys/vm/dirty_ratio:
   10
 
/proc/sys/vm/dirty_background_ratio:
   5
 
/proc/sys/vm/dirty_expire_centisecs:
   3000
 
/proc/sys/vm/dirty_writeback_centisecs:
   500
 
mandi is stopped
messagebus (pid  814) is running...
MSEC security policy on startup: disabled
MSEC permissions on startup: disabled
mtinkd is stopped
netconsole module not loaded
Configured devices:
lo eth0 wlan0
Currently active devices:
lo eth0 wlan0
rpc.statd is stopped
rpc.idmapd is stopped
nfsd is stopped
rpc.mountd is stopped
nscd (pid 2756) is running...
ntpd (pid  2806) is running...
numlock is enabled
oki4daemon is stopped
partmon has not been started, or check gave a failureportreserve dead but pid file exists
pppoe-status: Link is down (can't read pppoe PID file /var/run/pppoe.conf-pppoe.pid.pppoe)
pptp is stopped
resmgr is stopped
resolvconf is running
rpcbind is stopped
saslauthd (pid  2780) is running...
smbd is stopped
nmbd is stopped
Sound loaded
sshd is stopped
syslogd (pid  776) is running...
klogd (pid  806) is running...
ultrabayd is stopped
uuidd dead but subsys locked
Checking for VBoxService ...not running
winbindd is stopped
Wine Registration enabled
/etc/wlan/shared: line 71: [: too many arguments
wland is stopped
xfs (pid  2740) is running...
xinetd (pid  2116) is running...
[root@localhost gert]$ service -s

I am going to do a bit of thinking as I spot a new problem for me.  If 'service -s' is supposed to do all services, then why do I not see 'mysqld' in the listing??
« Last Edit: February 04, 2011, 03:41:34 AM by wedgetail »
32 bit: KDE (older) & various KDE-mini, ASUSTek P5P41D Rev X.0x, BIOS AMI0207 07/21/2009, "Pentium(R) Dual-Core CPU E5300 @ 2.60GHz", nVidia GeForce 9600 GT, 2x1GB Seagate Technology 1000528AS HDD
TV CompuPro VideoMate Vista E700 (not working in Linux), Acer X243HD LCD Screen

Offline AS

  • Hero Member
  • *****
  • Posts: 4111
  • Have a nice ... night!
Re: The 'service' in cli has changed on my system
« Reply #3 on: February 04, 2011, 03:45:03 AM »
> The answer was correct,  FAILED as I had not started 'mysqld' on boot up

It's not important here the result of status inquiry, it could be important to see the effect of the expanded commands, i.e. what the arguments really are
at the time the error show out
(/etc/init.d/mysqld: line 474: test: 11546: binary operator expected).

of course, you can try sh -x with any service you have installed that show up a failure.

AS

Online wedgetail

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2428
  • Any Bugs in site?
Re: The 'service' in cli has changed on my system
« Reply #4 on: February 04, 2011, 04:20:52 AM »
as
The exasperating thing is that I no longer get the "line 474" error but now at least I know the 'sh -x' for next time a service play up.
Have to contend with only line 71 problem if it is and why mysqld is not in the list of 'service -s'   :D
32 bit: KDE (older) & various KDE-mini, ASUSTek P5P41D Rev X.0x, BIOS AMI0207 07/21/2009, "Pentium(R) Dual-Core CPU E5300 @ 2.60GHz", nVidia GeForce 9600 GT, 2x1GB Seagate Technology 1000528AS HDD
TV CompuPro VideoMate Vista E700 (not working in Linux), Acer X243HD LCD Screen

Offline melodie

  • Hero Member
  • *****
  • Posts: 5942
  • XMMP=Jabber, free instant messaging protocol !
    • PCLinuxOS Fr
Re: The 'service' in cli has changed on my system
« Reply #5 on: February 04, 2011, 04:24:21 AM »
What is the problem exactly ? Mysql does not start ? If that is so:

What do you find in /var/log/mysqld ?

Have you tried to start it with the "mysqld_safe" command ?

/what does "sh -x" do exactly ?
melodie at swissjabber dot ch - IRC #pclinuxos-fr sur freenode

Offline AS

  • Hero Member
  • *****
  • Posts: 4111
  • Have a nice ... night!
Re: The 'service' in cli has changed on my system
« Reply #6 on: February 04, 2011, 05:00:08 AM »
> what does "sh -x" do exactly ?

assuming a shell script, using -x option it will be executed printing the expanded command in the script.

Looking at actual sample:
> /etc/wlan/shared: line 71: [: too many arguments

the  execution on my system of 'sh -x /sbin/service wlan status' show the following output
>
> + /etc/init.d/wlan status
> /etc/wlan/shared: line 71: [: too many arguments
> wland is stopped
> + exit 3

from here you can see that something is going wrong in /etc/wlan/shared, looking further in it: 'sh -x /etc/wlan/shared' produce the following:
+ '[' '!' -n '' ']'
+ ECHO=echo
+ '[' -x /sbin/modprobe ']'
+ MODPROBE=/sbin/modprobe
+ '[' -x /sbin/wlanctl-ng ']'
+ WLANCTL=/sbin/wlanctl-ng
+ '[' -x /sbin/wland ']'
+ WLAND=/sbin/wland
++ cat /proc/sys/kernel/hotplug

============================================
+ '[' -f /proc/sys/kernel/hotplug -a -x -a -f /etc/hotplug/wlan.agent ']'
/etc/wlan/shared: line 71: [: too many arguments
============================================

+ HAS_HOTPLUG=n
+ '[' -f /etc/wlan/wlan.conf ']'
+ . /etc/wlan/wlan.conf
++ WLAN_DEVICES=wlan0
++ ChannelList=01:02:03:04:05:06:07:08:09:0a:0b:00:00:00
++ ChannelMinTime=200
++ ChannelMaxTime=250
++ WLAN_SCAN=n
++ SSID_wlan0=
++ ENABLE_wlan0=y
+ for i in '/etc/wlan/shared.*'
+ [[ '' == *~ ]]
+ [[ '' == *.rpmsave ]]
+ [[ '' == *.rpmold ]]
+ [[ '' == *.rpmorig ]]
+ [[ '' == *\#* ]]
+ . /etc/wlan/shared.prism2
++ PRISM2DL=/sbin/prism2dl
+ FIRMWARE_DIR=/etc/wlan/

looking at script (/etc/wlan/shared) you will find the following source:

if [ -f /proc/sys/kernel/hotplug -a \
        -x `cat /proc/sys/kernel/hotplug` -a \
        -f /etc/hotplug/wlan.agent ] ; then
        HAS_HOTPLUG=y
else
        HAS_HOTPLUG=n
fi

clearly the statement `cat /proc/sys/kernel/hotplug` is not producing any output, thus leading to an invalid test statement:

+ '[' -f /proc/sys/kernel/hotplug -a -x -a -f /etc/hotplug/wlan.agent ']'
/etc/wlan/shared: line 71: [: too many arguments

got it ?  :)

AS


Online wedgetail

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2428
  • Any Bugs in site?
Re: The 'service' in cli has changed on my system
« Reply #7 on: February 04, 2011, 05:18:59 AM »
melodie
It is getting a bit confusing for me but this is what I experienced.

In my first post I showed with the first code insert window one of my simple ways of checking that 'mysql' was running. The last couple of days this failed. The result I decided to post in Forum.

As mythTV runs from another partition on the same hard drive I re-booted to the mythTV partition, also a KDE fully updated (until repo problems). Here I tested for 'mysql' and 'mysqld' operation as I have done many many times a couple of months ago and I did not find the same problem.  

When returning to the previous partition where I was running KDE and discovered the problem, I could no longer re-produce the error and I don't think it was just a matter of re-booting as I had already done that a few times.  Right now I am waiting on that particular error to show up again.

As a side effect I started looking closer at using 'service -s' which will give status for all services, as I understand.

Code: [Select]
[root@localhost gert]$ service -s
[root@localhost gert]$

This gives a rather long list which is not ordered, since I did not easily spot 'mysqld' I tried to '|grep mysqld'

Code: [Select]
[root@localhost gert]$ service -s |grep mysql
/etc/wlan/shared: line 71: [: too many arguments
[root@localhost gert]$

1.. mysqld appears not to be listed, and yet it is running
2.. the line 71 error also shows up

The original problem seems to have disappeared for the time being, in which case I have no use for 'service -s' which would be overkill for just checking on 'mysqld'.  At this stage it is only a couple of irritations that is left.   ;D

Code: [Select]
[root@localhost gert]$ ls -l /var/log/mysqld
total 0
[root@localhost gert]$

Code: [Select]
[root@localhost gert]$ mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.42 PCLinuxOS 2010 - MySQL Standard Edition (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases ;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.02 sec)

mysql>

To me it all seems well now, still interesting I find no log but I assume this is because I am not using mysql yet.
« Last Edit: February 04, 2011, 06:10:34 AM by wedgetail »
32 bit: KDE (older) & various KDE-mini, ASUSTek P5P41D Rev X.0x, BIOS AMI0207 07/21/2009, "Pentium(R) Dual-Core CPU E5300 @ 2.60GHz", nVidia GeForce 9600 GT, 2x1GB Seagate Technology 1000528AS HDD
TV CompuPro VideoMate Vista E700 (not working in Linux), Acer X243HD LCD Screen

Online wedgetail

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2428
  • Any Bugs in site?
Re: The 'service' in cli has changed on my system
« Reply #8 on: February 04, 2011, 05:28:22 AM »
as
Have I got it  ???  well yes and no, you are saying it is ok with that error ;D

I have dabbled a bit with scripts but this requires a nights sleep first and I will see if I can work my way through. Looks a bit on heavy side for me.

Thanks for the post, I am looking forward to have a real go at it but not tonight.  :)

Why is mysqld not in the list?
32 bit: KDE (older) & various KDE-mini, ASUSTek P5P41D Rev X.0x, BIOS AMI0207 07/21/2009, "Pentium(R) Dual-Core CPU E5300 @ 2.60GHz", nVidia GeForce 9600 GT, 2x1GB Seagate Technology 1000528AS HDD
TV CompuPro VideoMate Vista E700 (not working in Linux), Acer X243HD LCD Screen

Offline AS

  • Hero Member
  • *****
  • Posts: 4111
  • Have a nice ... night!
Re: The 'service' in cli has changed on my system
« Reply #9 on: February 04, 2011, 06:14:44 AM »
I made a fast check inside '/sbin/service' script, what I found is that it behave differently if you invoke it by

# service msqld status

from

# service -s

The first form is invoked as:

if ! is_ignored_file "$service" && [[ -f $servicedir/$service ]]; then
    $debug $servicedir/$service $options   <------------------------------------------------
    exit $?
else
    echo "Cannot find $service service"
    usage
fi

the second form is invoked as:

        if egrep -q '^([^#]*)status\)' $service;then
            $debug $servicedir/$service status
        fi

Actually the 'egrep' is failing (for a reason I don't know) on mysqld service, while it not fail on others (listed) services.
It could be either a non-compliance of the /etc/init.d/mysqld script or a bug in the '/sbin/service' script.

My idea however, is that if a service status should be checked, it should be invoked at same conditions in both case,
then I' m inclined toward a possible /sbin/service bug.

AS