parsed Posted May 17, 2009 Share Posted May 17, 2009 Hello everyone! Nice to see such a community dedicated to helping out with PHP. I hope someone can help me out with my issue. For some time now I have been trying to re-create this bash script into a pure PHP script and by searching online I found out that I needed libssh2, which I have installed now and confirmed is working. Unfortunately I have still not been able to re-create the script in pure PHP. I suspect that the server in question does not accept any commands once a shell has opened as a security measure and that what the bash script does is send the commands without opening a shell, which the server then accepts. Since I am new with both bash scripts and PHP I might be wrong in my suspicion and that something else might be wrong, but so far I have not managed to make any PHP script that worked. Hopefully someone here might help me out with this, I would appreciate it. This is the bash script: #!/bin/sh init=STATUS docool=YES doheat=YES id=AS52-356 key=/.ssh/id_rsa dir=/etc/slog/bak/ echo "mode='$init' cooldown='$docool' heatup='$doheat' device='$id'" | ssh -T -i $key root@server > /etc/slog/$init prevfile="$(ls $dir | sort -n | tail -n1)" docopy=0 if [ -z "$prevfile" ]; then docopy=1 else prevsum="$(md5sum $dir/$prevfile | cut -d\ -f1)" currsum="$(md5sum /etc/slog/$init | cut -d\ -f1)" echo "$prevsum $currsum" if [ "$prevsum" != "$currsum" ]; then docopy=1 else echo "No changes" fi fi if [ "$docopy" -eq 1 ]; then file="$dir/$init-$(date '+%Y%m%d-%H%M')" echo "Creating new $file" cp /etc/slog/$init $file else echo "No changes" fi Any ideas on how I can re-create the script as PHP? Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.