[OT] odd PHP/linux happening with a bash script?

29 views
Skip to first unread message

George Gallen

unread,
Jan 19, 2022, 4:12:54 PM1/19/22
to mvd...@googlegroups.com
<?php var_dump($argv); ?>

ok - run it directly - get what's expected.

$ php /tmp/check-arg.php -s test yellow bus
array(5) {
  [0]=>
  string(18) "/tmp/check-arg.php"
  [1]=>
  string(2) "-s"
  [2]=>
  string(4) "test"
  [3]=>
  string(6) "yellow"
  [4]=>
  string(3) "bus"
}

ok - so I want to run this script as if it were a command (it's a php script that replaces an existing command), so I created this script

$ vi /tmp/testingcommand
php /tmp/check-arg.php $1 $2 $3 $4 $5 $6 $7 $8 $9 $10

so I should be able to just

$ /tmp/testingcommand -s test yellow bus
array(6) {
  [0]=>
  string(18) "/tmp/check-arg.php"
  [1]=>
  string(2) "-s"
  [2]=>
  string(4) "test"
  [3]=>
  string(6) "yellow"
  [4]=>
  string(3) "bus"
  [5]=>
  string(3) "-s0"
}  

OK - so where did that "-s0" come from?  I've done some fiddling and it's what is in $argv[1] (-s) and a "0" (so in this case -s0)

Any ideas? happened on our RHEL7 as well as a Fedora 30 setup

since the script can be run either directly (php program.php) or via a script I can just ignore the last index of argv[]
I guess I could check argv[0] for '...php' and keep all indexs and if no ...php  then ignore last index

Odd

George Gallen

unread,
Jan 19, 2022, 4:17:17 PM1/19/22
to mvd...@googlegroups.com



From: mvd...@googlegroups.com <mvd...@googlegroups.com> on behalf of George Gallen <g_ga...@hotmail.com>
Sent: Wednesday, January 19, 2022 4:12 PM
To: mvd...@googlegroups.com <mvd...@googlegroups.com>
Subject: [mvdbms] [OT] odd PHP/linux happening with a bash script?
 
via a script I can just ignore the last index of argv[]

should have read

via a script i CANT just ignore the last index of argv[]

George Gallen

unread,
Jan 19, 2022, 4:43:21 PM1/19/22
to mvd...@googlegroups.com
so the problem is with:

php /tmp/check-arg.php $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 

needs to be

php /tmp/check-arg.php $1 $2 $3 $4 $5 $6 $7 $8 $9 $(10)
or
php /tmp/check-arg.php "$@"

George


From: mvd...@googlegroups.com <mvd...@googlegroups.com> on behalf of George Gallen <g_ga...@hotmail.com>
Sent: Wednesday, January 19, 2022 4:12 PM
To: mvd...@googlegroups.com <mvd...@googlegroups.com>
Subject: [mvdbms] [OT] odd PHP/linux happening with a bash script?
 
--
You received this message because you are subscribed to
the "Pick and MultiValue Databases" group.
To post, email to: mvd...@googlegroups.com
To unsubscribe, email to: mvdbms+un...@googlegroups.com
For more options, visit http://groups.google.com/group/mvdbms
---
You received this message because you are subscribed to the Google Groups "Pick and MultiValue Databases" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mvdbms+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mvdbms/BL0PR13MB4516AB2C3E59737A224F2378FA599%40BL0PR13MB4516.namprd13.prod.outlook.com.

Wol

unread,
Jan 19, 2022, 4:45:58 PM1/19/22
to mvd...@googlegroups.com
At a guess, is it limited to 10 arguments - 0-9? So it thinks $10 is
$1 concat "0" ?

Cheers,
Wol

On 19/01/2022 21:43, George Gallen wrote:
> so the problem is with:
>
> php /tmp/check-arg.php $1 $2 $3 $4 $5 $6 $7 $8 $9 $10
>
> needs to be
>
> php /tmp/check-arg.php $1 $2 $3 $4 $5 $6 $7 $8 $9 $(10)
> or
> php /tmp/check-arg.php "$@"
>
> George
>
> ------------------------------------------------------------------------
> *From:* mvd...@googlegroups.com <mvd...@googlegroups.com> on behalf of
> George Gallen <g_ga...@hotmail.com>
> *Sent:* Wednesday, January 19, 2022 4:12 PM
> *To:* mvd...@googlegroups.com <mvd...@googlegroups.com>
> *Subject:* [mvdbms] [OT] odd PHP/linux happening with a bash script?
> <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgroups.google.com%2Fgroup%2Fmvdbms&data=04%7C01%7C%7Cba4e1997a9034fc7fcf708d9db907651%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637782235781280860%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=uiAY5UpFMwg4Z%2Bb3xfi7F%2BDYk%2BtotSQX7cK7%2BKl8hYY%3D&reserved=0>
> ---
> You received this message because you are subscribed to the Google
> Groups "Pick and MultiValue Databases" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to mvdbms+un...@googlegroups.com
> <mailto:mvdbms+un...@googlegroups.com>.
> <https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fmvdbms%2FBL0PR13MB4516AB2C3E59737A224F2378FA599%2540BL0PR13MB4516.namprd13.prod.outlook.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=04%7C01%7C%7Cba4e1997a9034fc7fcf708d9db907651%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637782235781280860%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=lD5q1hrGh7avSMFmsxjegeQP7tI5deKS0faKuhSLIAs%3D&reserved=0>.
>
> --
> You received this message because you are subscribed to
> the "Pick and MultiValue Databases" group.
> To post, email to: mvd...@googlegroups.com
> To unsubscribe, email to: mvdbms+un...@googlegroups.com
> For more options, visit http://groups.google.com/group/mvdbms
> <http://groups.google.com/group/mvdbms>
> ---
> You received this message because you are subscribed to the Google
> Groups "Pick and MultiValue Databases" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to mvdbms+un...@googlegroups.com
> <mailto:mvdbms+un...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mvdbms/BL0PR13MB4516B4B7C4A8C876C5F0C36AFA599%40BL0PR13MB4516.namprd13.prod.outlook.com
> <https://groups.google.com/d/msgid/mvdbms/BL0PR13MB4516B4B7C4A8C876C5F0C36AFA599%40BL0PR13MB4516.namprd13.prod.outlook.com?utm_medium=email&utm_source=footer>.

George Gallen

unread,
Jan 19, 2022, 4:57:03 PM1/19/22
to mvd...@googlegroups.com
yeah, except instead of $(10) it should be ${10} - both worked though
but the "$@" was the key so if it did go over 10 arguments it wouldn't matter.

George


From: mvd...@googlegroups.com <mvd...@googlegroups.com> on behalf of Wol <antl...@youngman.org.uk>
Sent: Wednesday, January 19, 2022 4:45 PM
To: mvd...@googlegroups.com <mvd...@googlegroups.com>
Subject: Re: [mvdbms] Re: [OT] odd PHP/linux happening with a bash script? SOLVED
 
> For more options, visit https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgroups.google.com%2Fgroup%2Fmvdbms&amp;data=04%7C01%7C%7Cf466229433d540f256ee08d9db951463%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637782255615176220%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=9V%2FUanupI6By9DSYAVIq1n%2BFKACiVYNhExl1XXdK4ps%3D&amp;reserved=0
> <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgroups.google.com%2Fgroup%2Fmvdbms&amp;data=04%7C01%7C%7Cf466229433d540f256ee08d9db951463%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637782255615176220%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=9V%2FUanupI6By9DSYAVIq1n%2BFKACiVYNhExl1XXdK4ps%3D&amp;reserved=0>

> ---
> You received this message because you are subscribed to the Google
> Groups "Pick and MultiValue Databases" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to mvdbms+un...@googlegroups.com
> <mailto:mvdbms+un...@googlegroups.com>.
> To view this discussion on the web visit
> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fmvdbms%2FBL0PR13MB4516AB2C3E59737A224F2378FA599%2540BL0PR13MB4516.namprd13.prod.outlook.com&amp;data=04%7C01%7C%7Cf466229433d540f256ee08d9db951463%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637782255615176220%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=NRCi6zVP1DRNSsAepI23oY9QJs0RsmdHl1OipcRl37E%3D&amp;reserved=0
> <https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fmvdbms%2FBL0PR13MB4516AB2C3E59737A224F2378FA599%2540BL0PR13MB4516.namprd13.prod.outlook.com%3Futm_medium%3Demail%26utm_source%3Dfooter&amp;data=04%7C01%7C%7Cf466229433d540f256ee08d9db951463%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637782255615176220%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=UHROhWkBGb7H464ozfZQki2Zavpdk68KFZWKLSX84AQ%3D&amp;reserved=0>.

>
> --
> You received this message because you are subscribed to
> the "Pick and MultiValue Databases" group.
> To post, email to: mvd...@googlegroups.com
> To unsubscribe, email to: mvdbms+un...@googlegroups.com
> For more options, visit https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgroups.google.com%2Fgroup%2Fmvdbms&amp;data=04%7C01%7C%7Cf466229433d540f256ee08d9db951463%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637782255615176220%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=9V%2FUanupI6By9DSYAVIq1n%2BFKACiVYNhExl1XXdK4ps%3D&amp;reserved=0
> <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgroups.google.com%2Fgroup%2Fmvdbms&amp;data=04%7C01%7C%7Cf466229433d540f256ee08d9db951463%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637782255615176220%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=9V%2FUanupI6By9DSYAVIq1n%2BFKACiVYNhExl1XXdK4ps%3D&amp;reserved=0>

> ---
> You received this message because you are subscribed to the Google
> Groups "Pick and MultiValue Databases" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to mvdbms+un...@googlegroups.com
> <mailto:mvdbms+un...@googlegroups.com>.
> To view this discussion on the web visit
> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fmvdbms%2FBL0PR13MB4516B4B7C4A8C876C5F0C36AFA599%2540BL0PR13MB4516.namprd13.prod.outlook.com&amp;data=04%7C01%7C%7Cf466229433d540f256ee08d9db951463%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637782255615176220%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=DKBoCXeXemtXS%2FI27FLyGUYVS0TYeiFSy3MLPpyDq7A%3D&amp;reserved=0
> <https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fmvdbms%2FBL0PR13MB4516B4B7C4A8C876C5F0C36AFA599%2540BL0PR13MB4516.namprd13.prod.outlook.com%3Futm_medium%3Demail%26utm_source%3Dfooter&amp;data=04%7C01%7C%7Cf466229433d540f256ee08d9db951463%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637782255615176220%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=EvV6nYvRUvvSW5IrXcitDb8Cy2Dg%2F%2Bo6fGiIKcn9uM0%3D&amp;reserved=0>.


--
You received this message because you are subscribed to
the "Pick and MultiValue Databases" group.
To post, email to: mvd...@googlegroups.com
To unsubscribe, email to: mvdbms+un...@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "Pick and MultiValue Databases" group.
Reply all
Reply to author
Forward
0 new messages