LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 11-07-2005, 09:26 AM   #1
Basslord1124
Member
 
Registered: Jun 2004
Location: KY
Distribution: Debian, Mint, Puppy
Posts: 507

Rep: Reputation: 51
scripting question...


All righty, I was just wondering something. Is it possible to make a script that will call another script...but that script is not within the same language? Say a PHP script calling a BASH script or something?

What I am hoping to accomplish is that a username variable will get added to a MySQL Database via PHP or something...then another script will extract that username and add them as a system user so they can have their own directory for FTP and what not.

Could something like this be done. I have done PHP scripting but nothing like this...haven't done BASH scripting yet but willing to learn, especially to do what I am talking about here.
 
Old 11-07-2005, 09:38 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Yes. You just have to know what each item uses for input/output mechanisms.

For example in bash it uses variables which can be defined by name or by number if positional. So on the command line you type something like:

export TEST=<testarg>

within your bash script you just call the variable by prefixing its name with a $ for example:

echo "Now using $TEST within my script."

The above command would replace $TEST with whatever you'd typed in as <testarg> during the export.

A more common way though would be to use positional parameters. Any argument on the command line to a script gets a numeric value starting with 1 so that the first argument is $1, the next is $2 and so on.

So say you have a script named talkback.sh that just contains:

#!/bin/bash
echo "You typed $1"

Typing "talkback supecalifragilisticexpiallodocious" would result in:

You typed supecalifragilisticexpiallodocious

In Perl it uses argv[] as the input argument designator so your first would be argv[1], your second argv[2] and so on.

So you just need to know what PHP uses for such positional arguments to be able to pass one into it. I don't use PHP but am quite sure it must have such a mechanism.
 
Old 11-09-2005, 05:52 AM   #3
4mix
LQ Newbie
 
Registered: Jul 2004
Distribution: Debian 2.4.18
Posts: 19

Rep: Reputation: 0
to run a program from a php script use the function:
exec("/usr/sbin/yourscript");
or system("/usr/sbin/yourscript"); if I'm not wrong
You can run any program like this. Of course the path could be different

But make sure that there are the right privileges, and that you won't compromise the system security by doing this.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Scripting Question caps_phisto Linux - General 1 11-05-2004 02:43 PM
Scripting Question... Darklight451 Linux - Newbie 3 09-23-2004 05:03 PM
Scripting question sujte Linux - General 2 05-24-2004 04:52 PM
Scripting question aikitortoise Linux - Newbie 3 11-14-2002 05:18 PM
New to Scripting question s&j Linux - General 2 06-25-2002 08:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration