Shell Scripting

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

How can we Transfer one folder to another folder on windows server of big size about 300 GB. I have to do automation via Jenkins.
0
Upgrade your Question Security!
LVL 11
Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Where can I obtain a good tutorial on power shell scripting. Also where can I obtain canned scripts
0
Eventhough there are no big files there still /opt/ is showing 100% full it very confusing to me. Can anyone help me on this please


root@[opt] # lsof | grep -i deleted
root@[opt] #

Open in new window


root@[opt] # lvs
  LV          VG                  Attr       LSize   Pool Origin  Data%  Meta%  Move Log Cpy%Sync Convert
  isvol1      HKLVAUEDM08_applvg1 -wi-ao----  10.00g
  isvol2      HKLVAUEDM08_applvg1 -wi-ao----  10.00g
  isvol3      HKLVAUEDM08_applvg1 -wi-ao----  10.00g
  tsavol      HKLVAUEDM08_applvg1 -wi-ao----  10.00g
  wmstorage   HKLVAUEDM08_applvg1 -wi-ao----  10.00g
  homevol     rootvg              -wi-ao----   3.91g
  oprvol      rootvg              -wi-ao---- 320.00m
  optvol      rootvg              owi-aos---   3.91g
  optvolsnap  rootvg              swi-a-s---   3.94g      optvol  95.39
  rootvol     rootvg              owi-aos---   5.88g
  rootvolsnap rootvg              swi-a-s---   2.91g      rootvol 69.49
  scbmonlv    rootvg              -wi-ao----   1.00g
  semavol     rootvg              -wi-ao----   1.00g
  swapvol     rootvg              -wi-ao----   5.88g
  tmpvol      rootvg              -wi-ao----   3.91g
  usrctmvol   rootvg              -wi-ao----   2.94g
  usrgemsvvol rootvg              -wi-ao----   1.00g
  usropenvvol rootvg              -wi-ao----   1.97g
  varvol      rootvg              owi-aos---   3.91g
  varvolsnap  rootvg              swi-a-s---   3.94g      varvol  88.16

root@[opt] # df -PH | grep -i "/opt" | grep -i root

Open in new window

0
How Can I Copy Data From One Spreadsheet and append to another existing Spreadsheet?

INPUT
SourceWorkSheet
ID Name
1   ABC
2   XYZ

OUTPUT
MasterWorkSheet (Contains previous information + SourceWorkSheet info )
ID Name
11   DEF
22   USD
1   ABC
2   XYZ

Help would be appreciated.
0
I have created two jil files name AY.jil and PY.jil. I have three issues which are as follows:

1. how do you add a global variable value from a shell script program to a jil
    file?

2. PY.jil  needs to check every five minutes on the completion of the AY.jil
    jobs and AY.jil needs to check every five minutes on the completion of the
    PJ.jil jobs.

3.  How do you setup the watch_file in each jil to check every five minutes?
4.  How do you set up the success command for the file dependency?

I am getting this error :

I am only interested in reading in the global variable value 2 in PJ.jil:
  sendevent -E SET_GLOBAL -G "DIFF_VALUE=2"

Here is part of my shell script program:

while read DIFF_VALUE FLAG
do
	
	if [ "${DIFF_VALUE}" -ge "2" -a "${FLAG}" = "Y" ]
	then
		
		sendevent -E SET_GLOBAL -G "DIFF_VALUE=2"
		
	elif [ "${DIFF_VALUE}" -lt "1" -a "${FLAG}" = "N" ]
	then		
	        sendevent -E SET_GLOBAL -G "DIFF_VALUE="
	
	fi
done < ${DIFF_FILE}

Open in new window

Here are my jil progams (AY.jil and PY.jil):

Insert PJ_job: cmd_job
job_type: CMD
command: /path/to/script/script.sh  DIFF_VALUE=$${DIFF_VALUE=2}
watch_file: /path/to/script/AY.jil
watch_interval: time_in_mins
machine: machine_name
owner: user_name
condition: s(/path/to/AY.jil)

Insert AY_job: cmd_job
job_type: CMD
watch_file: /path/to/script/PJ.jil
watch_interval: time_in_mins
machine: machine_name
owner: user_name
condition: s(/path/to/PJ.jil)

Open in new window

0
Please see the attached XML, there are multiple resources,

I want to be able to find the resource whose name is "jdbc/PegaRULES" and create a new xml file which has only that resource.

For example: newfile.xml should be like:

<?xml version='1.0' encoding='utf-8'?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- The contents of this file will be loaded for each web application -->
<Context>

    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
	
<Resource
			auth="Container"
			name="jdbc/PegaRULES"
			type="javax.sql.DataSource"
			maxActive="100"
			maxIdle="30"
			maxWait="10000"
			username="user1"
			password="password1!"
			

Open in new window

0
Thanks to Rick_2CA - https://gallery.technet.microsoft.com/office/Mailbox-Pre-Archive-347f9162/view/Discussions

I have been able to Modify this script to include: TotalDeleteditemSize and TotalDeleteditemCount

This outputs the below and works exactly how I want:

ItemsCount      
ArchiveItemsCount      
ItemsSizeBytes      
ArchiveItemsSizeBytes      
TotalDeletedItemSize            
DeletedItemCount


The part I am having trouble with, and where I would like a push in the right direction is how to obtain the ArchiveTotalDeleteditemSize & ArchiveTotalDeleteditemCount (The count and size of data that CAN be archived, same as what is output from "ArchiveItemsSizeBytes")

Below is the script, that I have manipulated to include the

TotalDeleteditemSize & TotalDeleteditemCount......

I have attempted to match what was already in the script, by copying the code, and changing the values (Via Powershell ISE), However, I just end up with nothing being returned or getting the identical results as the ArchiveItemsizebytes

Essentially I am after the Archivable size & Count for recoverable deleted items

Any assistance would be greatly appreciated!!!

If I have worded anything wrongly, or something does not make sense, please let me know, and I will be happy to clarify...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


# Exchange 2010 Mailbox PreArchive Statistics
# Purpose:  Query mailboxes for mail older than X days in order …
0
#!/bin/sh

today=`/bin/date -d yesterday +%Y%m%d`
#sleep 600
server=`hostname`

ftp -n -i abcd_servername <<!
user username Pswd@123
bin
cd /home/abcd/
lcd /appl/aaa/logs/stats
mput total_$server.$today
mput number_$server.$today
bye
0
I have already written a GUI in Tk to consolidate all scripts at one place.
The logs are similar with some changing text.

Can you please help me in transforming my shell script to tcl and integrating it with the GUI .

I have attached the log file , shell script and the GUI code (unfinished)

Thanks

Abhi
segyqc.sh
test_segy.txt
log.log
0
i have a csv file populated with email addresses
i also need there SamAccountName
Rather than look each of these up
Is there a method that could query the email addresses in the csv and populate another column with the SamAccountName?
0
Vote for the Most Valuable Expert
LVL 7
Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

I have a mailbox with tons of folders ( over 50000 folders ) and the person put lot of special characters that we think it is causing the activesync problem keep reloading.

so I would like to know, is there a powershell script where I can identify the folder that have special characters and rename it ?
0
i have a code like this

#!/bin/ksh

exit()
{
echo "leaving the function "
exit $1 ## should call builtin function
}

if [ ${AUTORUN} = "Y" ]
then
echo "cannot AUTORUN"
exit 1      #should call user defined function
else
echo "can AUTORUN"
fi


is it possible to do it ?
0
I need help creating a Script that will Check if the Uptime(Hours) is exided on Windows 10 Operating Systems. I am not that Scripting guy just a newbie in the Scripting world.The following will be the Parameters I would like to have:

Parameter 1 specifies after how many hours without rebooting the user is asked via a message box  to restart their computer themself or to shut down .

Parameter 2 specifies after how many hours without restarting will the script plan an automatic restart in 60min (with no prompt for cancelling)


The script must be controllable with at least two parameters
Thank You in Advance
0
Hello Team,

Require a shell/perl script with below steps.
1) When disk space reaches 75%, trigger a cron job and move the old .arc files to another location.
2) Clean up the files in a folder by keeping only 8 hours of data available and it should be run every 15 mins.

Thanks,
Pra
0
Hello All,

I wanted to run the below script

Get-WinEvent @{logname='application';starttime=[datetime]::today } -ComputerName "ABCDEFRR56d" | select timecreated,task, TaskDisplayName

Put the output to a excel file and send email to a distribution list.

Can any one help me with a script?
0
I had this question after viewing Script for testing ping and telnet.

How can i modify this script to test telnet and mutual auth only

Expected Output
Flow ID |       From               |             To                      |          Test           |         STATUS
1            | 192.168.2.26:20  |    192.168.2.27:23       |       Telnet            |             OK
1            | 192.168.2.26:20  |    192.168.2.27:23       |       Mutual Auth |             OK
0
I am trying to create a script that I can use to log into remote pc's, on a domain, with admin privileges and uninstall software and then display a pop-up.

so far I have this: wmic /failfast:on /node:"D:\computers.txt" product where name="Java 8 Update 144" call uninstall /nointeractive

in some cases I also need to delete the registry keys.

 REG DELETE "HKEY_CLASSES_ROOT\Installer\Products\4EA42A62D9304AC4784BF2238110440F" /f

REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\4EA42A62D9304AC4784BF2238110440F" /f

REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\4EA42A62D9304AC4784BF2238110440F" /f

REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{26A24AE4-039D-4CA4-87B4-2F32180144F0}" /f

can you please help?
0
Hi I have a  data like below format

Site	Variable	Units	Model	29/00Z	29/06Z	29/12Z
CQT	500mbHeight	dm	MASS	588.4	589 	588.9
CQT	500mbHeight	dm	NAM	589.4	589.5	588.2

Open in new window


How can i transpose as one below (like repeat first 4 columns for transpose of each row after 4th column
CQT	500mbHeight	dm	MASS	29/00Z	588.4
CQT	500mbHeight	dm	MASS	29/06Z	589
CQT	500mbHeight	dm	MASS	29/12Z	588.9
CQT	500mbHeight	dm	NAM	29/00Z	589.4
CQT	500mbHeight	dm	NAM	29/06Z	589.5
CQT	500mbHeight	dm	NAM	29/12Z	588.2
CQT	500mbHeight	dm	NAM	29/18Z	589.6

Open in new window

0
Hi Im trying to display the output of the shell script in php.

When user login to the page it have to get the username and it should be passed to the shell script and that shell script output should be print on the webpage.In php the shell script is not getting executed

Please help me to make this.

PHP:-
<?php
session_start();
if(isset($_SESSION['username']))
{
$username=$_SESSION['username'];
$result = shell_exec('./get.sh >> temp.log');
echo "<pre>$result</pre>";
echo "<div id='User' style='float:right;color:#0000FF;' 'font-weight:bold;'>Welcome , " . $_SESSION[$result]. " </div>";
}
?>

Open in new window

Shell script:-
grep -A 1 "$username"  /mnt/eseesn60/ee_groups_see/ee_magicdraw/bittu/user.txt > /mnt/eseesn60/ee_groups_see/ee_magicdraw/bittu/get.txt
egrep -Ri ',' /mnt/eseesn60/ee_groups_see/ee_magicdraw/bittu/get.txt > /mnt/eseesn60/ee_groups_see/ee_magicdraw/bittu/getname.txt

Open in new window

0
Free Tool: ZipGrep
LVL 11
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.

Hi,

Please help me out for below problem...i want create the one shell script to upload file through lsftp and using below command but it is now working.

 lftp -oIdentityFile=/.ssh sftp://test:test@XX.XX.XX.XX -e "put tmp.txt.gpg; bye"
0
I am compressing files into one zip file and I am using the WSFTP script Editor/debugger and I want to rename the dest file to abc-yyyymmdd.zip. I am using the RENAME command as FirstFileName.txt abc-[YYYY][MM][DD].zip and that is what I get in the dest folder. I need the current date to be inserted.
0
Can someone help me out?  I need a shell script that can make an sftp connection with a password - installing the keys is not an option.  The scripts that I have (pasted below) throw an error saying that the command "expect" is not available.  Any help would be GREATLY appreciated.

#!/bin/sh

expect << 'EOS'
spawn sftp USERNAME@ip_address:/path/to/folder
expect "Password:"
send "PASSWORD\n"
expect "sftp>"
send "put file1\n"
expect "sftp>"
send "bye\n"
EOS
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
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
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

Shell Scripting

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.