Shell ScriptingSponsored by ConnectWise





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

Hi Experts,

Good Day..

 I have a shell script which moves files from one linux server to another.

As per the requirement , Output path folder contains space in between folder name ----outputserver/file out/date on file/.

According to my knowledge , If path contains space in between,command wont execute successfully.

Can anyone help on this how to proceed further..Is there anyway to give path with space like mentioned above.
Get expert help—faster!
LVL 12
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Hello Expert,

Could anybody please guide me what does the below command means and how it works .

# Set the environmental file/configuration file
. $(cut -d/ -f1-3 <<<"${PWD}")/bin/

Thanks in Advance.
Hi Experts,

I have shell scripts named as, , and one jar file also.

Have to call these all  files  from a single sh file ( ) by series not parallel.

Any help regarding this would he helpful.
Hi All,

Fetching the mail body content from FND_NEW_MESSAGES in Oracle apps and writing the text in a file(.txt) and mailing it to the recipient in Shell Script using mailx command.

Problem is Line breaks(\n\r)  are not getting transformed to the Mail body in the mail.(outlook).

How to avoid newline breaks getting lost while mailing from shell script.
Hi Expert,

I'm Looking for MySql DB Backup process in a Linux Machine which i want to schedule by crontab in a with every 3 days window duration.

Could anybody can guide me for basic shell steps and the back up steps .

Please let me know if there any additional information .

Thanks in Advance!
I followed a simple tutorial on how to schedule console applications (exe ) on windows scheduler. I came across "Puppet" and how it can be used to manage/configure such applications.
what is puppet and how can it be used  ?
Below is a sample of data in TABLE_FORMAT tables. I want to Compare the actual table names in SCOTT schema with the data in  TABLE_FORMAT.  Insert into TEST123 table the names of tables not meeting the naming convention in TABLE_FORMAT table. I  need help please.

The first query return a roll because  "SCR_00083_UB_ALL_FNL_2" fall within the naming format. The second query didn't return any row because "SCR_00083_UB_ALL_FNL_2t" doesn't falls within the naming format. I want to insert the name of tables that do not fall in the naming conversion.

 select * from (
select UPPER(TABLE_FORMAT) table_format, upper(replace(replace(replace(replace(table_format,'${TB_STAMP}','%'),'${SCENARIO}','%'),'${END_DATE}','%'),'_','\_')) new_table_format from AR9_EIP_TABLES_TEMPLATE) a
  2    3    where 'SCR_00083_UB_ALL_FNL_2' like new_table_format escape '\'
  4  ;

TABLE_FORMAT                             NEW_TABLE_FORMAT
---------------------------------------- ----------------------------------------
SCR_${TB_STAMP}_UB_ALL_FNL_2             SCR\_%\_UB\_ALL\_FNL\_2

select * from (
  2  select UPPER(TABLE_FORMAT) table_format, upper(replace(replace(replace(replace(table_format,'${TB_STAMP}','%'),'${SCENARIO}','%'),'${END_DATE}','%'),'_','\_')) new_table_format from AR9_EIP_TABLES_TEMPLATE) a
  3    where 'SCR_00083_UB_ALL_FNL_2t' like new_table_format escape '\';

no rows selected
Hi Team,

I have an procedure called get_employeename (p_empid number , p_name out varchar2) .

Iam invoking this sp from unix script , I need to capture the p_name into a unix shell variable , iam trying the below code but gives an error when i execute it.
empid =101
ename ='  '
sqlplus -S hr/orcl@payroll << EOF
set verify off
set echo off
set trim off
set term off
set timing off
exec get_employeename($empid,$ename);


Any help is really appreciated.
I am looking for a script that can tell me which components of office 2016 are installed.

To give you a better idea: if you open office setup on a pc that has office installed and select add/remove features, it will display a list of components that are present with some left out components X'ed out. That's what script output I would like to see.

be so kind to test your script with office 2016 standard (volume license) if possible. In another forum, I was already provided with this script, wich for some reason does only work on click2run office:
Add-Type –MemberDefinition '
 [DllImport("msi", CharSet = CharSet.Unicode)]public static extern uint MsiEnumFeatures(string szProduct,uint iFeatureIndex, string lpFeatureBuf, string lpParentBuf);
 [DllImport("msi", CharSet = CharSet.Unicode)]public static extern int MsiQueryFeatureState(string szProduct,string szFeature);
' -name "tools" -namespace MSI -EA SilentlyContinue
$result = 0
$cnt = 0
$GUID = '{90160000-008C-0000-0000-0000000FF1CE}'
while($result -ne 259){
    $id = ' '*39
    $parent = ' '*39
    $result = []::MsiEnumFeatures($GUID,$cnt,$id,$parent)
    if ([]::MsiQueryFeatureState($GUID,$id) -eq 3){

Open in new window


I have a text file where I want to combine the first and second row into one row. How do I do it using the
Do Until objFile.AtEndOfStream

Cloud Class® Course: Microsoft Azure 2017
LVL 12
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

I am trying to figure out how to ping a remote hostname and return only the IP address and store it into a text file.

Could someone help me out? I really appreciate your help in advance.
Hi All,
Pls may I know that
How to show the customized message box when opening the folder in map networks drive or explore for some specific users ??? Appreciate that someone can help me.

Thu zar
1. Can someone explain me if there is any changes in .cloginrc file, I need to run the rancid-cvs and rancid-run,
2. When i am trying to login i can see that the username is not pulling from what is there in .cloginrc.

For Eg:
(Under my clogin file)
I have mentioned
add user 1x.x.x User1
add password 1x.x.x       {password}
add method 1x.x.x telnet ssh

But when i am trying to login, i can see that username is in rancid. I am not sure why its happening. And to make sure that if try firewall login or normal login, its going with actual username only
This works:

do shell script "cURL -f http://mydomain/myfile.txt -o ~/Library/'Group Containers'/UBF8T346G9.Office/myFile.txt"

Open in new window

But extending the target path to include a second quoted folder fails:

do shell script "cURL -f http://mydomain/myfile.txt -o ~/Library/'Group Containers'/UBF8T346G9.Office/'User Content'/myFile.txt"

Open in new window

It raises an err:

Warning: Failed to create the file /Users/[username]/Library/Group

And in both cases, wrapping the full path in single quotes also fails at the same "Group" part of the path, eg:

do shell script "cURL -f http://mydomain/myfile.txt -o '~/Library/Group Containers/UBF8T346G9.Office/myFile.txt'"

Open in new window

What am I doing wrong?
I have a CVS file with thousands of lines and columns. I need to focus on column AM named or any column named  "EA-domain_list" in that row, I have several domains that are separated by commas in there.

Is there a way via perl, or some type of script that will feed this spreadsheet named master.csv in and take all the EA-domain_list that are in commas, and make new columns for each domain. Basically for example in summary

you look in the attached spreadsheet and look an AM you see,, I need what ever is in there to strip each domain into a new column like AS would be called EA-domain_list an in there would have, the another one row AT would have Keep in mind some times there are 20 of  then in there. So then I would like to spit out a new file called adjusted_domain_list.csv

Also, I am sorry I didn't mention previously that I am using a Macbook
Hi, for a reason or another any new DFS I'm creating can be mapped as usual, but it's not displayed for everyone.  All users have the same permissions on the NTFS and DFS shares.  

Not matter how (GPO or manually in shell) it's done it's not visible.   When I use net use x: \\\dfs-drive /y  I don't get an error, it's successful but the DFS share is not visible.  

When I map an DFS that has been created before this issue I have not problem.  All DFS have been created on the same DC, same security, same NFTS, same servers.  

Thank you
What VBA would I use that would download a file, but before doing so validate the file can be downloaded before attempting the pull. If possible please try to do this without using On ERROR. I'm trying to see if there is a solid way to check if a file can be downloaded without attempting the download first.

  • In the link above it would validate the file can be downloaded before attempting the download. If for any reason the file could not be downloaded a message box would appear stating "The file can not be pulled. The link may have changed."

  • I may have seen someone try to do this using Dos/Shell but couldn't get it to work at the time and don't remember where it is at.
I wrote the following script to send me the names of new users added to AD in the last day. It works fine as long as there was only one user added.

If none were added,  I get this:
Send-MailMessage : Cannot validate argument on parameter 'Body'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.

If multiple were added, I get this:
Send-MailMessage : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Body'. Specified method is not supported.

If only one were added, I get an email that displays the same stuff you'd get if you just had this as your script:
$When = ((Get-Date).AddDays(-1)).Date
Get-ADUser -Filter {whenCreated -ge $When} -Properties whenCreated

(though all I really want is the Distinguished Name.

Could someone please help me update this script so that:
1) If no users were added, I just get an e-mail saying no new users in the body.
2) If one, or more users were added, I just get a list of their Distinguished Names in the body of the email.

Here's the script as it stands now:
$When = ((Get-Date).AddDays(-1)).Date
$body1 = Get-ADUser -Filter {whenCreated -ge $When} -Properties whenCreated
$Subject = "New Users Added in Last Day"

$AdminName = ""
$Pass = Get-Content "\\mypath\cred.txt" | ConvertTo-SecureString
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $AdminName, $Pass

Send-MailMessage -To …
How can I change the below via an
Exchange Management Shell script so
Test #2 updates the same C:\.... location
that Test #1 does when I force updates ?
Test #1
  4am automatic update location
  ** C:\Program Files\Microsoft\Exchange Server\V14\ExchangeOAB
Test #2
  Manual "ANYTIME" update location
  ** C:\Program Files\Microsoft\Exchange Server\V14\ClientAccess\OAB
Cloud Class® Course: CompTIA Healthcare IT Tech
LVL 12
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Need your help to resolve the below query.  
I want to sum up the values for column4,column6,column7, column8,column10,column11 if value in column1 is duplicate.  
Also need to make duplicate rows as single row in output file i.e (column3 can have any of value from duplicates values in output file of column3 ex : can contain either abcd123,qwert or 345rty).   Also need to append all duplicate values of column3 of input file in column 12 of output file expect the one which we have already stored in column3 of output file (ex. column12 of output file can contain only in form qwert^345rty if value abcd123 is used in column 3 of outputfile

input file


Open in new window

output file


Open in new window

Tried below code, but it is not working and also no clue how to complete the code to get correct output

    awk 'BEGIN {FS=OFS="|"} FNR==1 {a[$1]+= (f4[key]+=$4;f6[key]+=$6;f7[key]+=$7;f8[key]+=$8;f10[key]+=$10;f11[key]+=$11;)} input.txt > output.txt

Open in new window

How can I pull the short name of user 502 (on a Mac) in a script to set the computer name?  For example, one laptop has user 502 w/ short name of msmith, I need msmith to be used in the following where $502-short-name would be msmith.  I tried the id command, but it returns too much info.

sudo scutil --set ComputerName-$502-short-name
sudo scutil --set LocalHostName $502-short-name
dscacheutil -flushcache


I need a script in bash. Which will inform me about new files in the directory. I am new in scripting that is why cant build script properly.

I think i can do this via "if then"  ow with while.

Case like this.
Somedays in the month it will be uploaded some files to the directory. After adding new files, i want to script notify me that new files added successfully.
Dear experts,

I am a chartered accountant, CIMA and CFA.

I have a lot of experience in writing excel formulae (the entire credit goes to this forum, thank you experts).

I now want to pursue Financial Engineering.

I am learning C, C++ now. Once I become well versed with these two languages, I will move to learning Python.

Now from robustness, depth and FE requirement is Python better or MATLAB

I am not sure I have the bandwidth to complete/learn both.

Till date I have been learning C and I did not struggle to pick up the synatax or logic.

Kindly advice.
Hi Experts,
could you pls help me how to check if directory exist using asterisk "*" in bash "if condition".
Basically would like to check if directory exist like *Drop* or best solution please

Below is the sample script
cd /home/mobaxterm; mkdir tmp tmp1  Child_Drop1 Child_Drop2 Child_Drop3 Child_Drop4 Child_Drop5


ls -ltr "${base}/"*Drop*
cp -r  "${base}/"*Drop* ${base}/tmp1/

if [ -d "${base_dir}" ] ; then
  echo "drop exists"
  cp -r  "${base}/"*Drop* ${base}/tmp1/
  echo "drop do not exists"

Open in new window

Thanks in advance
I have a unix shell script which is used to connect to oracle db. But the concern is the script has clear text password Is there a way not to have clear text password while connecting to oracle schema.

Shell ScriptingSponsored by ConnectWise





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.