Shell Scripting

9K

Solutions

10

Articles & Videos

6K

Contributors

The term 'shell' refers to a general class of text-based command interpreters most often associated with the UNIX and Linux operating systems. Popular shells include Bourne, Debian Almquist (dash), Korn (ksh), Bourne Again (bash) and the C shell family (csh). Some view the DOS 'cmd' prompt as a minimal shell of sorts. It is also possible to install Cygwin on Windows and emulate a full Unix environment with complete shell capabilities. Terminal emulators, such as xterm, GNOME Terminal and OS X Terminal, can be used to access shell.

Share tech news, updates, or what's on your mind.

Sign up to Post

I've never used Powershell to run scripts before so be gentle, this scripting stuff is very new to me :)

I just copied what I thought would be a very handy script from a Microsoft article that I saved as PatchScript.ps1, but when I try to run it in Powershell, I get the error:

File C:\1\patchscript.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details.
At line:1 char:21
+ c:\1\patchscript.ps1 <<<<
    + CategoryInfo          : NotSpecified: (:) [], PSSecurityException
    + FullyQualifiedErrorId : RuntimeException

I looked into signing and it seems like such a long winded process to go through just to run the occasional script I'm confident will be safe, so was wondering if there is an over-ride of some sort to run an occasional self created script?  

Or is there an easy way to temporarily disable the policy preventing the execution of scripts, and then re-enable that policy immediately afterwards to maintain the security that it provides?

Your help would be appreciated.
0
Announcing the Most Valuable Experts of 2016
LVL 6
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Hi Experts, how to pass (ignore) below line in regex. I'm  trying to achieve this in jenkins log parser plugin.

# Should pass
chmod: cannot access './config/temp_bkp_24072016/resources': Permission denied

# Should fail
chmod: cannot access './config/resources_bkp_24072016/resources': Permission denied

#regex rule. which I'm trying to handle above two scenario
warning /^(?!.*(temp_bkp))(.*Permission denied.*)$/

Open in new window



Thanks in advance
0
Hi experts,

I'm using grep inside a function by passing search string and log file to search for the string.
I call this function few times inside my bash script

This issue is, when no match found grep terminates/error out and it not processing further.

Sample
function printSummary ()
{
    local search_string="$1"
    local job_log="$2"

    grep  -irn -B 3 -A 3 "${search_string}" ${job_log} >> ${tmp_file}
}


printSummary 'unable to' /tmp/log #if string not found, it should continue to next two strings. but it error out here.
printSummary 'error at' /tmp/log
printSummary 'ORA-' /tmp/log

Open in new window



Thanks in advance.
0
hi All,

kindly help me to write a shell or python script to delete the weblogic files. The files are rotated but need to be deleted which are 30 days old. the find command doesn't delete the files because the number of files are huge.

below is the  .logs format of the weblogic servers
/wls1034/Middleware/user_projects/domains/Domain/servers/server3/logs/

server3.log00585
 server3.log00586
 server3.log00587
server3.log00588
server3.log00589
server3.log00590
server3.log00603
server3.log00604

server3.out00035
server3.out00034
server3.out00036
server3.out00037
0
Hello Folks,

I have a script that came along with a project that someone was working on and requested that I continue to use because the initial person who set it up had it running in the environment. Anyways the purpose of the script to check to see if the "ttt.service" was been stopped and restart the service if this is true.
 
Now I've added the script, given below to a .bat file and created a Scheduled task to run the file every 5 minutes to check and restart the service it never runs. I then opened a command prompt and attempted to run the script from the prompt and yet it still didn't work.

Not really sure what im doing wrong and need some assistance..

@echo on
for /F "tokens=3 delims=: " %%H in ('sc query ttt.Service ^| findstr "STATE"') do (  if /I "%%H" NEQ "RUNNING" (      net start ttt.Service  ))
0
The original filename is "test.txt".
The requirement is to append the date + Timestamp (format yyyymmdd_hhmmssmsi.txt) at the point the file "test.txt" is generated.


yyyy - year
mm - month
dd - day
ss - second
msi - milli-second
0
Hello,
I have in a shell script, a variable that uses xmllint like this:

Xpath_querry = $ (xmllint --shell $ {xmlfile} << EOF
    Setrootns << EOF
    Xpath count (// defaultns: $ {parse_tag /} / defaultns: $ {tag}))

This worked but now, I have an EOF error in the console at run time.
Would anyone know another way to rewrite this variable (that the variable is used later in the script)?
0
Currently have a script that has this in it and this portion works fine:

sshpass -p $pw ssh -q -t $user@$f sudo su -

$pw is the password the user types in
$user is the user of the script
$f is hostnames

What I would like it to do is
sshpass -p $pw ssh -q -t $user@$f sudo su - & cd /mnt/rsyslog/audits

But it doesn't seem to want to change directories.  

Do I need to have it call a script on the remote system for this to work?

Thanks
John

Update:  Attached is the generic version of my script
Line_Audit_Script.txt
0
Hi Experts
I need a batch file to change folder permissions and sub folders to the following
remove every users permissions except the administrator and the administrator only have the read only option
0
I currently login to the time from website using the following script.


browser = webdriver.Chrome('E:/Shared Folders/Users/runnerjp/chromedriver/chromedriver.exe')
browser.get("https://www.timeform.com/horse-racing/account/sign-in?returnUrl=%2Fhorse-racing%2F") 
time.sleep(3)
username = browser.find_element_by_id("EmailAddress")
password = browser.find_element_by_id("Password")
username.send_keys("usr")
password.send_keys("pass")
login_attempt = browser.find_element_by_xpath("//input[@type='submit']")
time.sleep(3)
login_attempt.submit()

Open in new window


it works but I find using Chrome web driver is hammering my CPU. Is there an alternative code I could use that does not mean I need to physically load the page to sign in?
0
[Webinar] How Hackers Steal Your Credentials
LVL 9
[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Hi,

If any one can help please, I need a power shell command  list name, email address and mailbox size in MB from a particular domain.  My environment is Exchange 2010 with 250 accepted domains. Thanks for your help in advance.
 
Thanks
Abdul
0
Hi,
I'm running a script on Unity to run multiple applications at the same time with different settings the problem is every time I try to run the .sh file it gives me an error : Player data archive not found at 'location', using local filesystem. I looked up on google but no one seems to have the answer to this problem, do you have any idea why this is hapenning?

Thank you!

Log file attached.
global_index.js
index.js
0
What is the easiest way to track and manage CIDR blocks/subnets?

I need to automate this processes when configuring/building a new environment to use a new CIDR block/subnets not already in use by other environments and add this information to a tracker?

So I want to have some sort of file that keeps track of all the CIDR blocks/subnets that are currently in use checks and gives me the next CIDR blocks available. How would I implement this logic?

  Client 1    10.172.0.0/22
            10.172.1.0/24 subnet
            10.172.2.0/24 subnet
            10.172.3.0/24 subnet
            10.172.4.0/24 subnet
client 2    10.173.0.0/22
client 3    10.174.0.0/22

            10.175.0.0/22  #Should give me this next available block

Open in new window

0
Hi,

I am a newbie in shell scripting!


I need to create a shell script that connects to the oracle 11g database and list all the tables that ends with _tmp (both lower case or upper case) and deletes them if it's equal or greater than 30 days.  I should be able to pass the variable parameters for database name, instance name and the number of days.  Also, it should skip SYS and SYSTEM schema tables but checks for all other schema tables in the database.

Please help me ASAP.

Appreciate it very much and thanks in advance.
0
Hi I want to create a script in SOLARIS server which rotates the logs of the instances being used. And also delete them after specific duration.Since , application logs being created in real time cannot be copied to other file tozip or delete them  as the writing of logs in actual file will be stopped.Pls tell me how to achieve this with a script.
0
Hi - I have downloaded the tcl curl solution to my windows 7 machine.  The directory is located in c:\tcl\lib\tcl8.6\tclcurl.  I am trying to run the https test case. When I run the https.tcl script, I am receiving the following error:

Could not init a curl session: invalid command name "::curl::init"

I have the curl exec downloaded and installed in my PATH environment directory.

Any thoughts?

Thanks for the assistance.
0
I need to Schedule she'll script to run in batch mode on unix using a detach screen.  I want the script to run in a screen I can reattach to later..  I need command to start script in screen.  I will schedule this script to run daily.
0
Hello experts,
I have a perl script that does the following::
-get log files from a directory;
-zip them
-send them over smtp to a given mailbox
-redownload them from the mailbox
-crypt them using pgp
-crypted files gets pushed on ftp
-delete the original file

What i would like to do is:
-Delete the ftp sending part, instead move the files in a local given directory

Attached you will find the script.

Thank you in advance!!!!
export.pl.txt
0
Hi Dears,
I want write a CLI for my centos, when a linux boot, it only accept my commands that i defined before,
is a sample for it?
Thanks,
0
Free Tool: ZipGrep
LVL 9
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

I had this question after viewing send ksh history to syslogd on AIX.

I'm trying to extend the above solution to bash on AIX, and bash and ksh on Solaris, with very little success. While I post my results, I wanted to know if someone has already done this before.

Thanks much in advance!
0
I had this question after viewing send ksh history to syslogd on AIX.

I used the solution above. Thanks to @woolmilkporc!

However, whenever the command includes a grep, it appears to spin off a job. Here's an example.

$ ls -l z*
z* not found
$ ls -l | grep z
[1] +  Done                    ls -l | grep z

I can't figure out why the job gets spun off when the command includes a grep.

Please can someone help?
0
I am using LAMP (Linux, Apache, MySQL, PHP) as my all in one production environment. Normally, I use MAMP (the Mac version of LAMP). The IT department of my employer set up a site in Ubuntu for me. They "defined" and "enabled" the root folder for my site. However, it appears if anything exists outside of the root folder, including other php files, I do not have access to it. For instance, I have a file structures similar to these:

root folder (which includes index.php)  ---> css folder ---> css files

root folder (which includes index.php) ---> php folder ---> php files (such as process-form.php)

How do I define other directories/folders in my site config file and enable them, so I can access them?

Mind you, ALL of this will have to be done through the MS-DOS Command Prompt.
0
I need to write a script to have a PC dump certain log files.  I have to use DameWare to get to these PC's, so i am remoted in.  After the files are dumped into (preferably) a .zip file, i would be set.  However, the dates change daily, as does the number of files.  Some days here may be 3 logs, some there may be 9 (or more).  I need help writing this script, as well as t-shooting the firewall problem.


Thoughts ..........?
0
Hi,

I have written a script in bash to create a volume from a snapshot and attach to an instance.  So Can I setup Cloudwatch monitoring that would trigger this script if the EBS volume is lost.
0
Hi ,

I have created one cloud image qcow2 for SLES 12U1 and inbuilt cloud-init too . but strange thing is this it boots sucessfully first time and we can work on it.but when we reboot it says unable to find /dev/sda1 or waiting for device.

I tried to change entries in fstab and grub.cfg with UUID but still same issue.

Please help might me i am nit changing it right but i refered links to do that and same issue.

same kind of thing happening with SLES11U4.
0

Shell Scripting

9K

Solutions

10

Articles & Videos

6K

Contributors

The term 'shell' refers to a general class of text-based command interpreters most often associated with the UNIX and Linux operating systems. Popular shells include Bourne, Debian Almquist (dash), Korn (ksh), Bourne Again (bash) and the C shell family (csh). Some view the DOS 'cmd' prompt as a minimal shell of sorts. It is also possible to install Cygwin on Windows and emulate a full Unix environment with complete shell capabilities. Terminal emulators, such as xterm, GNOME Terminal and OS X Terminal, can be used to access shell.