Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x

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

i'm trying to enable this "set-log Microsoft-Windows-PrintService/Operational /e:true" logging for each server and looking for how can I run for multiple server.

is it possible to do something like this to import. I know my line is not correct but looking for help here what I should correct to run multiple remote computer to enable this logging ?


----------------------------------------------------------------------
$servers = Import-csv "c:\Servers.txt"


foreeach($server in $servers){
     $cn=$server.Computername
     wevtutil set-log Microsoft-Windows-PrintService/Operational /e:true /r:"$cn"
}

----------------------------------------------------------------------
0
How to Use the Help Bell
LVL 10
How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

I have an Access DB, in it I have an authentication form for users, I want to import data using a powershell script, but when the script opens the DB fails to import because the form does not enter the access data. My code is this and I could not make it work

$database = 'D:\db.accdb'
$Acc = New-Object –comObject Access.Application
$Acc.Visible = $false
$Acc.OpenCurrentDataBase($database)
$Acc.DoCmd.OpenForm('Form_Login_bd')
$AccForm = $Acc.Forms.item('Form_Login_bd')
$AccForm.Controls.Item("txt_login").value = "Test_Admin"
$AccForm.Controls.Item("txt_contrasena").value = "Test_Admin123"
.
.
.
script to import data
.
.
.

Any idea how to solve it
0
Hi,
I have a requirement to fetch data in xls file using shell script, the requirement is simple whatever the table data that has to shown in xls file,

REGION_ID      REGION_NAME
1                      hello, you will be covering these many locations in this week
                        1.Perth
                        2.Sydney
                        3.Melbourne

I want to to show the same data in xls file but when I am generating it is not showing new line in xls cell instead the value is continued with the spaces which is incorrect.

wrong output - "hello, you will be covering these many locations in this week 1.Perth 2.Sydney 3.Melbourne"

for more please see the attached screenshot.

CREATE TABLE REGIONS
  ( REGION_ID NUMBER, REGION_NAME VARCHAR2(500)
  );
  
SET DEFINE OFF;
INSERT
INTO REGIONS
  (
    REGION_ID,
    REGION_NAME
  )
  VALUES
  (
    1,
    'hello, you will be covering these many locations in this week 
1.Perth 
2.Sydney 
3.Melbourne'
  );
INSERT
INTO REGIONS
  (
    REGION_ID,
    REGION_NAME
  )
  VALUES
  (
    2,
    'hello, you will be covering these many locations in this week 
1.NZ 
2.Tasmania 
3.NSW'
  );
INSERT
INTO REGIONS
  (
    REGION_ID,
    REGION_NAME
  )
  VALUES
  (
    3,
    'hello, you will be covering these many locations in this week 
1.Albany 
2.Busselton 
3.XYZloc'
  );
INSERT
INTO REGIONS
  (
    REGION_ID,
    REGION_NAME
  )
  VALUES
  (
    4,
    'hello, you will be covering these many locations in this 

Open in new window

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
There are two input files: input1.txt is the actual file, input2.txt contains count of value in column 1 as per coulmn 2 from input1.txt.
need output which remove lines from input1.txt  (output.txt for reference)


input1.txt>>
abc[1.0],partition=xyz,deployedTime=20170302T2316388270600
abc[2.5],partition=xyz,deployedTime=20160713T2040505210500
bca[2.3],partition=yxz,deployedTime=20160713T2040505210500
bca[2.4],partition=yxz,deployedTime=20160813T2040505210500
bca[1.2],partition=yxz,deployedTime=20170302T2316388270600
bca[2.4],partition=xyz,deployedTime=20160813T2040505210500
bca[2.3],partition=xyz,deployedTime=20170713T2040505210500

input2.txt>>
2 abc xyz
3 bca yxz
2 bca xyz

output.txt>> should be in below format(have to remove latest version of column 1 as per coulmn 2 from input1.txt based on deployedTime)

abc[2.5],partition=xyz,deployedTime=20160713T2040505210500
bca[2.3],partition=yxz,deployedTime=20160713T2040505210500
bca[2.4],partition=yxz,deployedTime=20160813T2040505210500
bca[2.4],partition=xyz,deployedTime=20160813T2040505210500


Need help for generic command, that will work if input file contains n number of line.
0
can i get any freelancers do powershell scripting
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
Newbie bash_scripting here and trying to get someone else's script to work on my system, slightly altered.

I think I'm very close. The goal is to have Filebot move & rename media, then use ffmpeg to remux the file and insert comment, and finally rclone move. My guess right now is that remux_video.sh isn't being handed the "$1" filename correctly, or FileBot doesn't have the correct rights to launch /usr/bin/ffmpeg

I have been at this for a while and managed to get FileBot out of the Snap sandbox to get this far.

This is my edited script:

#!/bin/bash

#RCLONE_ACD_POINT="acdtest:media"
RCLONE_ME_POINT="/home/me/dir3/"
METADATA_COMMENT="TEST-COMMENT"
MOVIE_FORMAT="Movies/{n} ({y}) {vf}/{n} ({y}) [{vf}]{' CD'+pi}{'.'+lang}"
TV_FORMAT="TV Shows/{n}/{episode.special ? 'Special' : 'Season '+s.pad(2)}/{n} {episode.special ? 'S00E'+special.pad(2) :
s00e00} {vf}{'.'+lang}"
LOG_FILE="/home/me/log/Proc.log"
LOCK_FILE="/home/me/log/filebot.lock"
EXCLUDE_LIST="$1/Proc.txt"
EXEC_EACH="/usr/local/bin/remux_video.sh '{file}' '$METADATA_COMMENT'"

if mkdir "$LOCK_FILE"
then
        # remove directory when script finishes
        trap 'rm -rf "$LOCK_FILE"' 0

        if [ "$#" -ne 2 ]; then
                echo "filebot_process.sh <in_dir> <out_dir>"
                exit 1
        fi

        # get absolute paths
        IN="$(realpath $1)"
        

Open in new window

1
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
Ask an Anonymous Question!
LVL 10
Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

I have a script that I am running on a server.  It calls a script on another server which starts three applications on another server and is supposed to return and finish running on the first server (if that makes sense). The problem is it runs the three commands in the script on the remote server, but it doesn't exit and return to the first server.  It hangs.  I have tried an exit, kill $$, kill $0, all to no avail.

Here is the line of code that calls the script on the remote server:
ssh -q ${servertwo} '/ppm/inetsvc/startppm'

Here is the entire script which is called on the remote server.  Again, it hangs at the end and doesn't return to the original server:

#!/usr/bin/ksh
# .profile entries
umask 022
export JAVA_HOME=/usr/jdk1.8.0_25
export ORACLE_BASE=/oracle
export ORACLE_HOME=/oracle/product/db11204
export PATH=$HOME/bin:$JAVA_HOME/bin:$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PPM_SERVER_CONF_DIR=/ppm/shared/conf
alias ppmhome="cd /ppm;ls -ltr"

cd /ppm/bin
./kStart.sh -name HPPPM_SVC2
sleep 80
./kStart.sh -name HPPPM_TU2
sleep 80
./kStart.sh -name HPPPM_TU4
kill $0

Any help would be greatly appreciated.

Thanks,
David
0
Hi,

I have a log file that has its entries separated by timestamp:

2017-08-31 12:18:10,362Z [lTaskScheduler4] TRACE c.g.a.v.n.c.r.AbstractRepository          : Ope
2017-08-31 12:18:10,363Z [lTaskScheduler4] TRACE c.g.a.v.n.c.r.CouchbaseOperations         : DBf
2017-08-31 12:18:10,363Z [lTaskScheduler4] TRACE c.g.a.v.n.c.r.AbstractRepository          : Oper
2017-08-31 12:18:10,364Z [lTaskScheduler4] TRACE c.g.a.v.n.c.r.CouchbaseOperations         :
2017-08-31 12:18:10,364Z [lTaskScheduler4] TRACE c.g.a.v.n.c.r.AbstractRepository          : Operation db.read.customer: 1 ms

And I have this command to filter and count certain lines of this log:

cat bug.log | grep notiStatus | grep HandleDownedure | grep "Bion" | grep -v "Executes"  | wc -l


But I need to separate this count for this log file to a count after 2017-08-31 07:00:00.000Z

And also a count before 2017-08-31 07:00:00.000Z

How can I put this in the command line?

Tks,
JT
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
Hey there,

I have an Exchange 2016 Hybrid setup with O365. All active users will be in the cloud, however terminated users will be migrated back to on prem and either left in the database for a term or exported to a PST. What I'm trying to do is to get my powershell script to pause until the batch completes and then continue on with some other tasks. I am aware of the Out-Null option but I don't think that's going to work in this case, as I need to confirm progress/completion after querying the status. I thought about using an Outlook rule that kicks off the remainder of my script after the migration notification is sent out but that relies on an outlook profile. Is it possible to do what I'm looking for or do I need something else in play here?

Thanks!
0
Basically I need to run the script with paths related to the shell script file location, how can I change the current directory to the same directory as where the script file resides?
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
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
Free Tool: IP Lookup
LVL 10
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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,

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

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.