bash script + php


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting bash script + php
# 1  
Old 09-05-2010
Question bash script + php

Hello,
I want to move some of my bash scripts to php ( add samba user, add new PC in dhcp and etc. ).With Google, I found some articles for bash and php, but there is only simple examples, nothing for variables.
Example:

Code:
#!/bin/bash
status=`/usr/local/etc/rc.d/isc-dhcpd status`
############
echo -n "Enter hostname: "
read host
echo -n "Enter MAC: "
read mac
echo -n "Enter IP: "
read ip
echo -n "Restart dhcp(y/n): "
read dhcp
echo "host $host { " >> dhcpd.conf
echo "hardware ethernet $mac;" >> dhcpd.conf
echo "fixed-address $ip;" >> dhcpd.conf
echo "}" >> dhcpd.conf
if [ $dhcp = y ];then
echo "/usr/local/etc/rc.d/isc-dhcpd restart"
echo "$status"
else
echo "Done"
fi

So I want to have a php field for $host, field for $mac and field for $ip.
Is there some articles or examples for this?
I have some php shells, but they are full with s*its.I wana to learn something.
Thanks

Last edited by mrowcp; 09-05-2010 at 01:21 PM..
# 2  
Old 09-05-2010
there is plenty of tutorials on the web. google php cli
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

In Bash shell - the ps -ef shows only the /bin/bash but the script name is not displayed

In Bash shell - the ps -ef shows only the /bin/bash but the script name is not displayed ? Is there any way to get the script names for the process command ? --- Post updated at 08:39 AM --- in KSH (Korn Shell), my command output shows the script names but when run in the Bash Shell... (3 Replies)
Discussion started by: i4ismail
3 Replies

2. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies

3. Shell Programming and Scripting

Different behavior between bash shell and bash script for cmd

So I'm trying to pass certain json elements as env vars and use them later on in a script. Sample json: JSON='{ "Element1": "file-123456", "Element2": "Name, of, company written in, a very weird way", "Element3": "path/to/some/file.txt", }' (part of the) script: for s... (5 Replies)
Discussion started by: da1
5 Replies

4. Web Development

Passing variable from PHP to bash script

I am totally new to PHP and I am trying to create a script that will as a user for a hostname and then use the "hostname" variable to generate a report using REST API. I am able to create the html script and php script to GET the "hostname" but I am having trouble passing the hostname variable... (10 Replies)
Discussion started by: kieranfoley
10 Replies

5. Shell Programming and Scripting

PHP parametric + bash script combination

Hello, I have a simple bash script and I manually run this script to put a file into related directory in apache normally. I need to run it in php with parameter. My target is to get a download link by running below script but I do not know anything about php. Here is my bash script: run.sh... (6 Replies)
Discussion started by: baris35
6 Replies

6. UNIX for Dummies Questions & Answers

Integrating bash script into php (page)

I have written a bash script...now i need to call the script from php page. Can you give me an example to demonstrate how it is done?:( (1 Reply)
Discussion started by: xerox
1 Replies

7. Shell Programming and Scripting

Execute interactive bash menu script in browser with PHP

I have an interactive menu script written in bash and I would like use PHP to open the interactive bash menu in a browser. Is this possible? Using the sytem() function in php runs the script but it's all garbled. Seems like maybe a terminal window needs to be opened in php first? ... (1 Reply)
Discussion started by: nck
1 Replies

8. Shell Programming and Scripting

General Q: how to run/schedule a php script from cron jobs maybe via bash from shell?

Status quo is, within a web application, which is coded completely in php (not by me, I dont know php), I have to fill out several fields, and execute it manually by clicking the "go" button in my browser, several times a day. Thats because: The script itself pulls data (textfiles) from a... (3 Replies)
Discussion started by: lowmaster
3 Replies

9. Shell Programming and Scripting

how to make your bash script run on a machine with csh and bash

hi, i have a script that runs on bash and would like to run it on a machine that has csh and bash. the default setting on that machine is csh. i dont want to change my code to run it with a csh shell. is there any way i can run the script (written in bash) on this machine? in other words is there... (3 Replies)
Discussion started by: npatwardhan
3 Replies

10. Shell Programming and Scripting

passing variable from bash to perl from bash script

Hi All, I need to pass a variable to perl script from bash script, where in perl i am using if condition. Here is the cmd what i am using in perl FROM_DATE="06/05/2008" TO_DATE="07/05/2008" "perl -ne ' print if ( $_ >="$FROM_DATE" && $_ <= "$TO_DATE" ) ' filename" filename has... (10 Replies)
Discussion started by: arsidh
10 Replies
Login or Register to Ask a Question