Shell Scripting

10K

Solutions

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

Hi

I am using ShellExecute  to open  Brother label printer file.  The code works perfectly!

Often, I need 2 or more identical labels.    In such cases, I would like to direct the printer job to print multiple copies per Shell Execute command (see code).
The reason for this is that  label printer produces waste at the beginning of each print job (by design).    If I print multiple copies then waste is reduced.

I appreciate any help.
Thank you.



Option Compare Database
Option Explicit

Const Dir As String = "C:\!!Tools\Microsoft Access\Labels"
Const TheFile As String = "P- 12MM OLT - Cable - CSP.lbx"
Const SW_SHOW = 5
  
Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, _
ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Sub btnPrint_Click()
    ShellExecute Me.hwnd, "print", Dir & "\" & TheFile, vbNullString, vbNullString, SW_SHOW
End Sub

Open in new window

0
Cloud Class® Course: Amazon Web Services - Basic
LVL 12
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Hi Expert

I have an Office 365 that uses several domains (@domain1.com, @domain2.com, @domain3.com, @domain4.com, etc...)
Mailboxes can can have one or more aliases using these domains.

I am wanting to change the user principal email address of all users whose current user principal email address is @domain2.com to become @domain3.com. I do not want to change any mailboxes that have @domain1.com or @domain3.com as their UserPrincipalName

If possible, I would like to also search for and add the @domain2.com domain with there are aliases using @domain2.com

... And finally, I would like to have a test mode so I can do a test run before I go and blast every mailboxes in this tenancy with the wrong details!

Here are are a couple of examples

john@domain1.com
  • Stays as is

jane@domain2.com
  • Add jane@domain3.com,
  • Make jane@domain3.com the UserPrincipalName,
  • and leave jane@domain2.com as an alias

peter@domain2.com which has also an alias of paul@domain2.com
  • Add peter@domain3.com and paul@domain3.com to the mailbox
  • Leave peter@domain2.com & paul@domain2.com as aliases
  • Make peter@domain3.com his UserPrincipalName


Note: I did some reasearch before posting this question. I found something similar in https://o365info.com/adding-email-addresses-using-powershell-bulk-mode-office-365-part-4-13/ ... but it goes through ALL the mailboxes rather than the mailboxes with one given domain.

Can you assist?

Thanks

Alexandre
1
Morning all, I'm looking for some code that will enable IE and Chrome to go fullscreen when the web page opens. We have a number of browsers, so a single bit of code would be great.

I've added the current code I have.

What would be the best method to achieve this?

Many thanks

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Edward</title>
</head>
<body bgcolor="#000000">
<!--url's used in the movie-->
<!--text used in the movie-->
<!--
:
Min
Sec
-->
<!-- saved from url=(0013)about:internet -->
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="1280" height="1024" id="Edward" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="Edward.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#000000" /><embed src="Edward.swf" quality="high" bgcolor="#000000" width="1280" height="1024" name="Edward" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</body>
</html>

Open in new window

0
simple Shell script to start a tom cat server (JVM) and if for some reason if server does not start within 3 mins exit and  also find any hung jvm tomcat start commands fired and force kill it.
0
I recently got some help writing a powershell script that listed all my AD users with their display name, ad account name and email address. Now I have a request for a similar list but this time a column for first name, last name and limited to active users only. Then the same thing with only deleted users. I supposed another column for active users Y or N would also be acceptable if it is easier. There is the last script  Get-Mailbox -ResultSize unlimited | select name, SamAccountName, primarysmtpaddress | Export-Csv c:\results.csv

I assume there must be a parm for first name and last name, but how can I determine if an account is active or disabled?
0
Dear Experts,

What is the best way to deployment network printers with presets to mac clients?
On Windows we use a print server with printing defaults and all clients connected through the print server gets those presets.

We need to get a similar experience to our Mac users.

The preset is pretty easy actually:  We are telling the printer to print the first page of every document from tray 2 and every following pages from tray 3 or 4.

I would like to deploy the printer via MDM. I think a script would be the best solution, but couldn't find the option to print the first page differently.

I know you can set this option through word settings, the problem here is, that I can't deploy this is a proper manner.

I was also thinking about an AppleScript in combination with Automator.  


Let me know what you think about my ideas.

Regards SGTA14
0
Having an issue with some BASH scripts --

crontab has a script it runs every 10 minutes and is set to send stdout & stderr to /dev/null.  

However, it runs some sub-scripts and service restarts and these subscripts are ignoring the redirect to null and generating  unnecessary emails.

What I am not understanding is how stdout & stderr are inherited if at all ?   >/dev/null &2 > 1  by bash scripts run inside a bash script.

Looked at a lot of google links but they are no help.  

TIA
0
I'm working in Oracle Linux 7.   We are moving to this environment from AIX and I'm trying to run the shell scripts in Linux that worked fine in AIX.

One of the scripts passes variables to another shell script by doing "su - oracle" so that the called script will run in Oracle's environment since it does sqlplus to the database to execute a procedure.

For some reason, when using the "su - oracle", the variables do not get passed.  Grrrr

The calling script, named "read_log", is executed by root and passes the variables this way:

#!/bin/bash
 su - oracle -c /dbscripts/run_SQL_insert_proc $UOWNER $UTABLE_NAME $UCOLUMN_NAME $COLUMN_VALUE

The called script, named "run_ora_proc" is owned by oracle and does the sqlplus.   I do an "echo" at the beginning of the script but the variables are empty.  The $0 does show the script name though.

#!/bin/bash
echo "passed variables are " "$0" "$1" "$2" "$3" "$4"

Screen output is:

passed variables are  /dbscripts/run_ora_proc

The shell environment for both root and oracle users is "bash".

What am I doing wrong?
0
I must delete queue on WebSphere MQ - IBM ,
What are the commands to use on an AIX server?
0
Hi Team,

I need to validate the date in the below format dd-MON-YYYY  in a shell script. Iam very new to shell script, Any help will be helpful.
12-JUN-2008
28-Feb-2009 , I want to make sure , the date for the feb month is valid .

Any help is really appreciated.
0
Cloud Class® Course: Python 3 Fundamentals
LVL 12
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Hello,
Im trying to translate this code from https://securionpay.com/docs/api#checkout-request-sign.
EXAMPLE SIGNING


export checkout_request='{"charge":{"amount":499,"currency":"EUR"}}'
export signature=`echo -n "$checkout_request" | openssl dgst -sha256 -hmac 'pr_test_tXHm9qV9qV9bjIRHcQr9PLPa' | sed 's/^.* //'`
echo -n "$signature|$checkout_request" | base64
        

EXAMPLE SIGNED CHECKOUT REQUEST


Y2Y5Y2UyZDgzMzFjNTMxZjgzODlhNjE2YTE4Zjk1NzhjMTM0Yjc4NGRhYjVjYjdlNGI1OTY0ZTc3OTBmMTczY3x7ImNoYXJnZSI6eyJhbW91bnQiOjQ5OSwiY3VycmVuY3kiOiJFVVIifX0=
				

Open in new window


to Ruby on Rails

I ended with

       
 checkout_request='{"charge":{"amount":5,"currency":"EUR","capture":true}}'
 secret_key = 'sk_test'
 @signature = Base64.urlsafe_encode64(OpenSSL::HMAC.hexdigest('sha256', checkout_request, secret_key) + "|" + checkout_request)

Open in new window


which isn't valid and its not exacly translation of the script.

When i test shell version with my secret key it works.
I tried Base64.urlsafe_encode64, encode64, strict_encode65, I tried digest instead of hexdigest. All kinds of way because I desperatly can't make it work. I think its about checkout_request data because it translates to this
 
2.5.0 :001 > '{"charge":{"amount":5,"currency":"EUR","capture":true}}'
 => "{\"charge\":{\"amount\":5,\"currency\":\"EUR\",\"capture\":true}}" 

Open in new window

and therefore signature is created with `\` before quote

question on stackoverflow: https://stackoverflow.com/questions/51506282/json-and-generating-signature
0
Looking for a script to bulk disable UAC and reboot remote servers so we can run remote installs. Looking at powershell as one scripting method since available on servers. Can look at also ding WMI.  Just any solution would be great better than doing it manual for each one. The good news we are admins on all the servers.
0
I've tried to Google this, but I guess I'm just not using the right terminology as I can't come up with an answer.

I'm looking for a way (command line, powershell, vbs script, group policy) that will make one of the icons in the notification area always show. (I'm talking about the area to the left of the time/date, where the power, network and volume typically always show).

I'm running Windows 10 Enterprise in an AD environment.

Just to make sure I'm explaining what I'm trying to do in an automated fashion correctly, here is what I do to do it manually:

RIght click on taskbar
Click Tasbar settings
Under "Notification area" click "Select which icons appear on the taskbar
In the resulting list, find the thing I want to show up all the time, and move the slider to "On"
Close out of settings

Thanks!
0
Anyone can share an efficient script (Javascript or any other) that
does BitCoin mining?
0
Dear Experts,

On AIX I need to compare 2 files holding percentage space usage:

Format:

hn5691    :   /appli/oltb/apache/logs     72 %
hn5785    :   /appli/logs/REPORTING     38 %
...

If the percentage in the second file is 10% higher than in first file it should write that in a file (so that can be mailed).
Idea is to catch a looping process.

I'm not enough into awk to make it work, your help is appreciated.
I attach 2 files to work with.

Many thanks in advance.
W.
file2.txt
file1.txt
0
Hi guys

We have an Exchange 2010 environment on Windows 2008 R2.

How do you export all of the mailboxes, their usernames/aliases but also the organisational unit that their usernames are part of into a CSV?

You already helped me export the mailboxes and their usernames, which worked great. I would like to add organisational units into that CSV also, is this possible?

Thanks for helping
Yashy
0
I want to write a script for automatically restoring the database from back-upset . can you please help me to provide that in case if someone has written it .

Thanks,
Merlin.s
0
hi guys

So I got some help from EE experts to run a command in Exchange shell to export all mailbox statistics/data.

One of the important things is for me to work out the LastLoggedOnTime so that I can segregate the oldest mailboxes from the actively used ones.

I ran a tool called Inactive Users Tool by Solarwinds and exported it. When I compare the last logged on time of one user from the Exchange shell formula to the data exported from the Solarwinds one, they are different. I have many users who have not logged on for years, but somehow are showing as two days ago in the Shell statistics.

Perhaps the Solarwinds tool is using the Inactive users by looking at a different attribute?


Any ideas on why that would be?

Thanks for helping
Yashy
0
Hi guys

We have Exchange 2010 SP3 and I was hoping you could help me pull out an Exchange report that will put everything below into separate columns in an Excel file. It can be ascending or descending based on mailbox size:

FirstName
SecondName
DisplayName

AccountName or Alias
MailboxSize (GB)
LastLoggedOnTime
Mailbox Database Name

Can you help me with this?

Thanks for helping
Yashy
0
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.

Hi,

I would like to request an assistant.

I would like to make a redirect using .htaccess .

The condition that i would like to combined are as follows :

1. redirect any access from /supporttickets.php to https://support.domain.com

2. redirect any access from  /submitticket.php to  https://support.domain.com/Tickets/Submit

3. redirect any access from   /contact.php to https://www.domain.com/contact.php

4. redirect any access to "billing" folder to https://billing.domain.com

5. IGNORE all above rules if the access file are "fpx_indirectcallback.php" or "fpx_directcallback.php"


Appreciates anybody assistant on this issue.
0
Hi guys

I'm trying to output mailbox sizes, account names, lastlogon time using Exchange Management shell by running the below:

Get-MailboxStatistics  -Server “ServerName” | Select DisplayName, sAMAccountName, LastLoggedOnUserAccount, ItemCount, TotalItemSize, LastLogonTime,  | Sort-Object TotalItemSize -Descending | Export-CSV c:\Folder Name\Filename.csv

I input all of the details where the quotes are, but then for some reason the SamAccountName section is always blank. Can someone help me with that please so that I can have the account names exported also?

Thanks for helping
Yashy
0
I have one access_log under main folder and have to copy that access_log under another folder where external FTP Server can able to download the log automatically.

My Question is Access_log generated in server for Whole day but we need to have only access_log for 15minutes using diff command.

Please let me know the diff command to be used for changing filename automatically everytime once the diff checked between two files.
0
Hi Experts,

I want to compare directories only on two servers, without files inside each directory.
I was hoping to get output telling me what directories are missing.

Below command works but doesn't tell that parent directory31 is missing on server1.
Is it possible to get just missing directories between two server paths without copying anything?

[sat@server directory]$ rsync -n -av --include='*/' --exclude='*' --delete /home/sat/directory/ sat@server1:/home/sat/directory/
sat@server1 password:
sending incremental file list
./
directory1/
directory1/directory2/
directory1/directory2/directory3/
directory11/
directory11/directory12/
directory11/directory12/directory13/
directory21/
directory21/directory22/
directory21/directory22/directory23/
directory31/
directory31/directory32/
directory31/directory32/directory33/
 
sent 385 bytes  received 63 bytes  179.20 bytes/sec
total size is 0  speedup is 0.00 (DRY RUN)
[sat@server directory]$

server output

[sat@server directory]$ pwd
/home/sat/directory
[sat@server directory]$
[sat@server directory]$
[sat@server directory]$ ll
total 16
drwxrwxr-x 3 sat sat 4096 Jul 12 14:32 directory1
drwxrwxr-x 3 sat sat 4096 Jul 12 14:33 directory11
drwxrwxr-x 3 sat sat 4096 Jul 12 14:33 directory21
drwxrwxr-x 3 sat sat 4096 Jul 12 14:37 directory31
[sat@server directory]$

server1 output

[sat@server1 directory]$ pwd
/home/sat/directory
[sat@server1 directory]$
[sat@server1 directory]$ ll
total…
0
Hi Experts,
pls refer this question. would like to extend bit further on masking the pwd values when we have more than one properties in a file.

https://www.experts-exchange.com/questions/29107089/Display-file-content-but-mask-password-value-in-bash.html
Solution from above question
cat /path/to/property//file|sed -e 's/db_password=.*/db_password=xxxxxxxxx/i'

Open in new window


could you pls help me how to mask two properties in single go please

hostname=server1
db_sid=oracledb
db_username=scott
db_passowrd=tiger
username_wls=weblogic
password_wls=welcome1
target_script_dir=/u01/app/oracle/scripts
target_db_client_home=/u01/app/oracle/db/client_1
0
I need to replace a line in a configuration file and want to make sure it's done safely since it needs to be done on several systems.

The line in the file is:
*.emerg                                                 *

Open in new window

I want to replace the end of line * on only lines that start with *.emerg with :omusrmsg:* so it looks like this:
*.emerg                                                 :omusrmsg:*

Open in new window

This sed command seems to work, but was curious if there was a more full proof way to do it:
sed -i '/^\*.emerg/s/\*$/:omusrmsg:*/' config.conf

Open in new window

0

Shell Scripting

10K

Solutions

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.