Donate to CWP

Your donations will be allocated to upgrades and further developments.
Click to know more about donations

Custom Modules

Get Custom modules for your CWP.
Get Custom Modules

Managed Support

Get Managed Support for your servers.
Click Here for more info

One Time Support

Do you need One Time support? Get Fast Support Here

Function: shell exec, exec and system


exec — Execute an external program without output.
system — Execute an external program and display the output.
shell_exec — Execute command via shell and return the complete output as a string.

functions sends shell command to server as root user, but you need to use full path for this to work.
It’s god to use <pre></pre> for all server commands as then you get displayed informations same as on server over eg. putty.

examples without <pre></pre>:
echo shell_exec(“/bin/cp -R /home/user1 /backups/user1″);
echo shell_exec(“/bin/ls -la /root”);

examples with <pre></pre>:
echo “<pre>”. shell_exec(“/bin/cp -R /home/user1 /backups/user1″) . “</pre>”;
echo “<pre>”. shell_exec(“/bin/ls -la /root”) . “</pre>”;

commands with /bin path
arch ed link ping6 tar
awk egrep ln ps taskset
basename env login pwd tcsh
bash ex ls raw touch
cat false lsblk readlink tracepath
chgrp fgrep mail red tracepath6
chmod find mailx rm traceroute
chown findmnt mkdir rmdir traceroute6
cp gawk mknod rnano true
cpio gettext mktemp rpm umount
csh grep more rvi uname
cut gtar mount rview unlink
date gunzip mountpoint sed usleep
dd gzip mv sh vi
df hostname nano sleep view
dmesg ipcalc netstat sort ypdomainname
dnsdomainname iptables-xml nice stty zcat
domainname iptables-xml-1.4.7 nisdomainname su
echo kill ping sync

commands with /sbin path
MAKEDEV ctrlaltdel fdisk getkey ipmaddr losetup mkswap portrelease route sln udevadm
addpart debugfs findfs halt iptables lsmod modinfo portreserve rpcbind start udevd
agetty delpart fixfiles hwclock iptables-1.4.7 matchpathcon modprobe poweroff rsyslogd start_udev unix_chkpwd
arp depmod fsck ifcfg iptables-multi mii-diag mount.tmpfs ppp-watch rtmon status unix_update
arping dhclient fsck.cramfs ifconfig iptables-multi-1.4.7 mii-tool nameif quotacheck runlevel stop weak-modules
badblocks dhclient-script fsck.ext2 ifdown iptables-restore mingetty netreport quotaoff runuser sulogin wipefs
blkid dumpe2fs fsck.ext3 ifenslave iptables-restore-1.4.7 mke2fs nologin quotaon scsi_id sushell
blockdev e2fsck fsck.ext4 ifup iptables-save mkfs pam_console_apply rdisc securetty swapoff
cbq e2image fsck.ext4dev init iptables-save-1.4.7 mkfs.cramfs pam_tally2 reboot service swapon
cfdisk e2label fsfreeze initctl iptunnel mkfs.ext2 pam_timestamp_check reload setfiles switch_root
chcpu e2undo fstab-decode insmod killall5 mkfs.ext3 partx resize2fs setsysfont sysctl
chkconfig ether-wake fstrim insmod.static ldconfig mkfs.ext4 pidof restart sfdisk tc
clock ethtool fuser install-info load_policy mkfs.ext4dev pivot_root restorecon shutdown telinit
consoletype faillock genhostid ip logsave mkhomedir_helper plipconfig rmmod slattach tune2fs