Unable to run .sh file which creates a new folder and generates logs into it

Hi Team,

I am trying to run startOSWbb.sh, file from /u01/oswbb path which executes and initiate calls to other .sh files which creates one folder by of Archive and collects the logs of OS processes utilization status.

After running manually the startOSWbb.sh file, it creates a new folder by name of “Archive” and generates all the logs in path \u01\oswbb\Archive.

I have prepared below action script, which is getting executed properly and all the actions mentioned below are getting completed as per action info but the new folder “Archive” and logs are not getting generated.

Kindly help me here. Thanks in advance.

prefetch 4158e0bce768582e4d9fb926b6e91901822ce493 sha1:4158e0bce768582e4d9fb926b6e91901822ce493 size:3612052 http://HBIEMPRDAPP1.hbctxdom.com:52311/Uploads/4158e0bce768582e4d9fb926b6e91901822ce493/oswbb812.tar.tmp sha256:91448e561952c2dcb94f12fb4a300e17b897fc485fcc94808ed529068fe446bf
extract 4158e0bce768582e4d9fb926b6e91901822ce493

delete __createfile
delete "/tmp/startOSWbb.sh"
delete "/u01/oswbb812.tar"
move “__Download/oswbb812.tar” "/u01/oswbb812.tar"
Createfile until EOF
#!/bin/sh
cd /u01
tar -xvf oswbb812.tar
chmod -R 777 oswbb
cd oswbb
./startOSWbb.sh
EOF
move __createfile "/tmp/startOSWbb.sh"
wait chmod 777 "/tmp/startOSWbb.sh"
wait sh "/tmp/startOSWbb.sh"
wait chmod 777 "/u01/oswbb/startOSWbb.sh"
wait sh “/u01/oswbb/startOSWbb.sh”

Does your startOSWbb.sh script have any dependency on environment variables associated with your profile or the root profile? If so, try the following:

wait sudo su - root -c “/path/script.sh”

Many moons ago it was explained to me by @gearoid that the BESClient in NIX doesn’t run with full environment, so the above invokes the root environment for that “wait” execution.

You may also want to redirect standard error and output to a log file to see more details from the script execution. This would be helpful if there’s something else going on.

Hope this helps.

Best,
@cmcannady

2 Likes

Hi cmcannady,

Thanks for your response!

I have tried to run the script by updating provided action, but it has completed with exit code 1.

But while checking at endpoints side, there was only .tar file copied and startOSWbb.sh file created. .tar file was not untarred there.
Kindly review the action script and let me know, if I have missed any thing there?

Thanks in advance.

Dear Team,

Pl help me here.

Thanks,
Pramod

I would suggest maybe trying full paths in your createfile script. Rather than cding into /u01, just give it the full path to your .tar file and your .sh script?

Do you have the BESClient log from this action execution? Which line specifically is returning the exit code 1? Have you checked your SH file to see what could be returning exit code 1?

15:06:49 +0530 - mailboxsite (http://HBIEMPRDAPP1.hbctxdom.com:52311/cgi-bin/bfgather.exe/mailboxsite15519732)
Downloaded ‘http://HBCHATP01.hbctxdom.com:52311/mailbox/files/4d/93/4d931877ee857ab421d658d75d8abbf6de60379f’ as 'Action 2019362.fxf’
Gather::SyncSiteByFile adding files - count: 1
At 15:06:49 +0530 -
Successful Synchronization with site ‘mailboxsite’ (version 107) - 'http://HBIEMPRDAPP1.hbctxdom.com:52311/cgi-bin/bfgather.exe/mailboxsite15519732
Processing action site.
At 15:06:50 +0530 - mailboxsite (http://HBIEMPRDAPP1.hbctxdom.com:52311/cgi-bin/bfgather.exe/mailboxsite15519732)
Relevant - Software Distribution - Deploy: OS_Watcher_Linux_Latest_5th_Jul_18 (fixlet:2019362)
At 15:06:50 +0530 -
ActionLogMessage: (action:2019362) Action signature verified for Downloads
At 15:06:51 +0530 -
ActionLogMessage: (action:2019362) Non-Distributed - DownloadsAvailable
ActionLogMessage: (action:2019362) Action signature verified for Execution
ActionLogMessage: (action:2019362) starting action
At 15:06:52 +0530 - actionsite (http://HBIEMPRDAPP1.hbctxdom.com:52311/cgi-bin/bfgather.exe/actionsite)
Command succeeded (Prefetch download manager collected file) prefetch 4158e0bce768582e4d9fb926b6e91901822ce493 sha1:4158e0bce768582e4d9fb926b6e91901822ce493 size:3612052 http://HBIEMPRDAPP1.hbctxdom.com:52311/Uploads/4158e0bce768582e4d9fb926b6e91901822ce493/oswbb812.tar.tmp sha256:91448e561952c2dcb94f12fb4a300e17b897fc485fcc94808ed529068fe446bf (action:2019362)
Command succeeded extract 4158e0bce768582e4d9fb926b6e91901822ce493 (action:2019362)
Command succeeded delete No ‘/var/opt/BESClient/__BESData/actionsite/__createfile’ exists to delete, no failure reported (action:2019362)
Command succeeded delete No ‘/u01/startOSWbb.sh’ exists to delete, no failure reported (action:2019362)
Command succeeded delete No ‘/u01/oswbb812.tar’ exists to delete, no failure reported (action:2019362)
Command succeeded move “__Download/oswbb812.tar” “/u01/oswbb812.tar” (action:2019362)
Command succeeded createfile until (action:2019362)
Command succeeded move __createfile “/u01/startOSWbb.sh” (action:2019362)
Command started - wait chmod 755 /u01 (action:2019362)
At 15:06:53 +0530 -
Report posted successfully
At 15:06:53 +0530 - actionsite (http://HBIEMPRDAPP1.hbctxdom.com:52311/cgi-bin/bfgather.exe/actionsite)
Command succeeded (Exit Code=0) wait chmod 755 /u01 (action:2019362)
Command started - wait chmod 700 -R /u01/.ssh (action:2019362)
Command succeeded (Exit Code=1) wait chmod 700 -R /u01/.ssh (action:2019362)
Command started - wait chmod 755 -x /u01/startOSWbb.sh (action:2019362)
Command succeeded (Exit Code=1) wait chmod 755 -x /u01/startOSWbb.sh (action:2019362)
Command started - wait sudo su - root -c “/u01/startOSWbb.sh” (action:2019362)
Command succeeded (Exit Code=1) wait sudo su - root -c “/u01/startOSWbb.sh” (action:2019362)
At 15:06:53 +0530 -
ActionLogMessage: (action:2019362) ending action
At 15:06:53 +0530 - mailboxsite (http://HBIEMPRDAPP1.hbctxdom.com:52311/cgi-bin/bfgather.exe/mailboxsite15519732)
Not Relevant - Software Distribution - Deploy: OS_Watcher_Linux_Latest_5th_Jul_18 (fixlet:2019362)
At 15:07:41 +0530 -

Hi,

I tried to run as per your suggestion, but again it is showing as exit code 1. I have pasted some of the lines from logs.

Kindly suggest here.