Skip to main content

Hi guys,



We've been supplied a pearl script that we need to run @ login on each mac.



I'm trying to pass variables to it, but am sadly not use to pearl & as this script is for a proprietry solution (NetConsent is the program fyi) I'd not be comfortable re-writing it in bash.



Anyways. What I have so far is:



&Debug ("Username is: $3");
&Debug ("domain (0) is: $2");
&Debug ("NETconsentServer is: $6");



This runs at login. So $2 & $3 are populated then via the jamf binary. $6 is passed as a parameter via the policy.



Pretty normal stuff, but the script does not seem to get these variables.



NETconsent Debug: Username is:
NETconsent Debug: domain (0) is:
NETconsent Debug: NETconsentServer is:



Any idea?



Ben Toms
IT Support Analyst GREY Group
The Johnson Building, 77 Hatton Garden, London, EC1N 8JS
T: +44 (0) 20-3037-3819 |
Main: +44 (0) 20 3037 3000 | IT Helpdesk: +44 (0) 20 3037 3883

I am not the strongest perl user, but I think you can do either of
these in the scripts to invoke one or the other and run them in
transparency.



#!/usr/bin/perl



use Shell;
bunch of shell commands



or if you are using a shell script



#!/bin/bash



some shell commands



/usr/bin/perl >> EndOfPerlscript



bunch of perl commands



EndOfPerlscript


Cool..



How would you then tell it to use perl again?



Or do you one line the commands?



i.e.



use shell $username=$3;



Ben Toms
IT Support Analyst GREY Group
The Johnson Building, 77 Hatton Garden, London, EC1N 8JS
T: +44 (0) 20-3037-3819 |
Main: +44 (0) 20 3037 3000 | IT Helpdesk: +44 (0) 20 3037 3883


@ARGV is the perl equivalent of shell's $*



So you should be able to set your variables with something like this:



($variable1, $variable2, $variable3) = @ARGV;



OR



$variable1 = $ARGV[0];
$variable2 = $ARGV[1];
$variable3 = $ARGV[2];


or you can look at get_opts and pass things with -i 123.0.0.1 on the command line and then use $opt_i in the script.


Reply