microsoft / shell-intune-samples

Sample shell scripts for Intune admins.
MIT License
637 stars 213 forks source link

SampleScript not Working #71

Closed telit0 closed 1 year ago

telit0 commented 1 year ago

I am trying to customize the SampleScript although I get a syntax error on the logging function:

line 921: syntax error near unexpected token `>'
line 921: `    exec > >(tee -a "$log") 2>&1'
theneiljohnson commented 1 year ago

Can you post the rest of the script?

From: telit0 @.> Date: Tuesday, 4 October 2022 at 16:07 To: microsoft/shell-intune-samples @.> Cc: Subscribed @.***> Subject: [microsoft/shell-intune-samples] SampleScript not Working (Issue #71)

I am trying to customize the SampleScripthttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fshell-intune-samples%2Fblob%2Fmaster%2FApps%2FLatestSampleScript%2FinstallIntuneApp4.00.zsh&data=05%7C01%7Cneiljohn%40microsoft.com%7C3453747eed184c75ffea08daa61a255b%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638004928501688362%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=1QABPpD46V49Uuzr2VYVu%2Ba5MVYcKBUY3rb1ByCAe0c%3D&reserved=0 although I get a syntax error on the logging function:

line 921: syntax error near unexpected token `>'

line 921: ` exec > >(tee -a "$log") 2>&1'

— Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fshell-intune-samples%2Fissues%2F71&data=05%7C01%7Cneiljohn%40microsoft.com%7C3453747eed184c75ffea08daa61a255b%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638004928501844560%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Sm8N%2FnTu7Q1Pb43hOxD6lR%2FpLLsdvlNuelYnYeZIOT0%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAGOC2JMJE4UNJJY6X466BZ3WBRB23ANCNFSM6AAAAAAQ4VKZCE&data=05%7C01%7Cneiljohn%40microsoft.com%7C3453747eed184c75ffea08daa61a255b%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638004928501844560%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=kXgIcR1B1GZqffkEX41k9Lf0JmwXn0tJbxyt2QLH1F8%3D&reserved=0. You are receiving this because you are subscribed to this thread.Message ID: @.***>

telit0 commented 1 year ago

The problem is on the startLog function, if I comment the call to this the script works.

function startLog() {

    ###################################################
    ###################################################
    ##
    ##  start logging - Output to log file and STDOUT
    ##
    ####################
    ####################

    if [[ ! -d "$logandmetadir" ]]; then
        ## Creating Metadirectory
        echo "$(date) | Creating [$logandmetadir] to store logs"
        mkdir -p "$logandmetadir"
    fi

    exec > >(tee -a "$log") 2>&1

}
theneiljohnson commented 1 year ago

Closing this, it seems to be working correctly everywhere i'm using it at the moment. If you still struggle, open again and i'll work with you to troubleshoot.