473,800 Members | 2,282 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing SOME command-line options to another script

2 New Member
I have a set of several scripts. One, called "mach-list" lists all machines that match specified criteria (e.g., all Solaris machines). Others (e.g., "mach-run") do things on multiple machines; they call mach-list to get the list of machines.

mach-list has command-line options. When you call mach-run, you can include on mach-run's command line the options for mach-list. How does mach-run know which options to pass to mach-list?

I thought of the following methods.

A marker: e.g., mach-run could have syntax like the following:
mach-run [ mach-list-options // ] [ mach-run-options ] arguments...
"//" is the marker; everything before it is an option for mach-list.
  • I don't want to use "--", because mach-run might want to use "--" for something else.
  • Doesn't have to be "//", but it's easy to type.

Separate file: have a subroutine/module in a separate file that processes mach-list's options:
  • options not related to mach-list will remain in the command line (so mach-run can process them)
  • mach-list, mach-run, etc. will all call/include this subroutine/module
  • the subroutine/module will set environment variables used only by mach-list

Does anyone have a better idea? Thanks.
Jun 6 '10 #1
5 1548
numberwhun
3,509 Recognized Expert Moderator Specialist
Can all of your requirements be met in one file, or even let files? You can always fork new processes and have any information found put into a file that can be read in after the forked process exits. Just a thought.

Regards,

Jeff
Jun 6 '10 #2
RonB
589 Recognized Expert Moderator Contributor
Jeff,

FYI, this Q is cross posted
http://forums.devshed.com/perl-progr...ml#post2478755
Jun 6 '10 #3
toolic
70 Recognized Expert New Member
Another possibility is to make a copy of mach-run's @ARGV then pass it directly to mach-list. This might require both scripts to ignore any irrelevant options:

Expand|Select|Wrap|Line Numbers
  1. # inside mach-run
  2. my @argv_copy = @ARGV;
  3.  
  4. # now process @ARGV
  5.  
  6. ...
  7.  
  8. system "mach-list @argv_copy";
Jun 6 '10 #4
haimroman
2 New Member
Regarding numberwhun's answer: I'm not sure what "let files" are, but it sounds similar to the idea of environment variables: a common storage. Files are trickier, because these are not daemons/services but commands, and more than one person might be running them at a time.

cross-posting: is that a problem? I thought DevShed was a separate site from this, though I noticed both sites seem to use the same forum software.

Regarding toolic's answer (copying @ARGV): interesting idea. I'd prefer invalid options be caught. But I'll think about this.

Thanks! (different ideas are still appreciated)
Jun 7 '10 #5
numberwhun
3,509 Recognized Expert Moderator Specialist
First, I meant to say "less" files, sorry. By forking the process, you could do what you need to do and once the fork returns to the current script for processing, it would continue, thus, cutting down on the need for multiple scripts/files.

As for the cross posting, you will find there are a lot of people here who participate in other forums as well. Their letting us know that the question(s) are cross posted allows us to see if an answer was provided prior and if that answer helped or not.

Regards,

Jeff
Jun 8 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
17359
by: zlatko | last post by:
There is a form in an Access Project (.adp, Access front end with SQL Server) for entering data into a table for temporary storing. Then, by clicking a botton, several action stored procedures (update, append) should be activated in order to transfer data to other tables. I tried to avoid any coding in VB, as I am not a professional, but I have found a statement in an article, that, unlike select queries, form's Input Property can't be...
7
4209
by: m7b52000 | last post by:
Some time ago I wrote a little program in Tcl/Tk that took the values from 3 sliders and performed a calculation using these values. The calculation was of course automatically repeated each time a slider was moved. It is proving most difficult in Python. How do I pass the .get() values to my calculating function? Do I use the command option for each slider? e.g command = Calc(a.get()). Obviously not cos it doesn't work. I am not a...
3
8126
by: whatduck | last post by:
I'm having trouble passing a variable that contains spaces. If the variable contains a space I get the following error: "Application uses a value of the wrong type for the current operation." If I pass a variable with out any spaces the procedure executes without error. I have a procedure on SQL Server 2000 with the following variable: Create Procedure Zproc_Demand_Matrix
2
5279
by: Bob | last post by:
I'm new to Access projects and SQL server and am not a veteran VB programmer. There's a cry for help! I'm attempting to print the current form on screen by using a command button which the user clicks once they have selected the desired record. The button calls a report which uses a stored procedure as its record source. The SP has 2 input parameters, one of which is a datetime data type. In the input parameters data field of the...
11
3188
by: Arsen Vladimirskiy | last post by:
Hello, If I have a few simple classes to represent Entities such as Customers and Orders. What is the proper way to pass information to the Data Access Layer? 1) Pass the actual ENTITY to the Data Access Layer method -or- 2) Pass some kind of a unique id to the Data Access Layer method
1
3844
by: Mike | last post by:
Hello, How do I pass variables to a command text.(C#)Because of the quotes,it seems that the values are not passed. Thanks, Mike
3
1215
by: Andrew Banks | last post by:
I'm using guid to generate primary keys for my SQL server DB I'm now trying to query the DB but keep getting errors. It seems to be erroring when passing the ID and it's always around a hyphen in the sring I'm passing Eg. WHERE ID = '24646a31-c088-41da-b93c-32174588da48' errors near a31 WHERE ID = 'f7a9b89a-cbf6-4f40-aafe-7a861214ddcc' errors near f40
4
2098
by: shade73 | last post by:
Hey all. I currently have two seperate namespaces and I'm trying to pass a connection around to them. I want to use the same connection & leave it open for 6 methods & then close it. However, all 6 of those methods use that same connection. So my solution was to pass the SqlConnection as a parameter in each method. This works, but it goes super slow. When I changed it back and put the methods all back in the same namespace & didnt...
2
2447
by: | last post by:
I want to know how to make a clickable button or Command field on a GridView, and have the user's action a) fire a function and b) pass a data value from one of the GridView's columns to that function. Long version: ASP.NET's usual paradigm with master-detail editing is to have you define a commandfield, and on your detail view to define a second datasource that uses the SelectedValue of the GridView to determine what the detail record...
2
5063
by: Hakan Örnek | last post by:
Hi , I want to parameter passing to my windows sevice. I call service commands like this ; '------------------------------------------------------------ Dim sc As ServiceController sc = New ServiceController("ProsetLogServices") sc.MachineName = "." If sc.Status = ServiceControllerStatus.Stopped Then sc.Start() End If
0
9691
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10505
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10276
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10035
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5471
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.