A script is a sequence of commands or instructions that are executed by an interpreter program rather than compiled into a standalone executable program.

learn more… | top users | synonyms (2)

0
votes
2answers
506 views

VLC script on ubuntu server

I need a small script which run three vlc command on the same time (on Ubuntu server 14.04) as stated below: #!/bin/sh cvlc -vvv v1 --sout ...
7
votes
1answer
179 views

Know which process does I/O without iotop

On Linux, I want to know which process uses my disk I/O bandwith. I know I can use iotop but I have a machine where, for various reasons, iotop cannot be installed. How can I manually get that ...
0
votes
0answers
18 views

How to grouped the following variable and command and read 1 by 1

I've following array and variable : httpurl="http://www.nnin.com" firstquery=$(curl -s -X POST -d "UID=user1&PWD=1111" $httpurl) name="firstcust" ip="105.105.0.1" httpurl="http://www.mmim.com" ...
9
votes
4answers
11k views

Automated ssh-keygen without passphrase, how?

I would like to make an automated script that calls ssh-keygen and creates some pub/private keypairs that I will use later on. In principle everything works fine with.... ssh-keygen -b 2048 -t rsa -f ...
1
vote
2answers
443 views

How to convert text or character to hex in korn shell

Does the unix korn shell provide a function to convert text or character to hex eg. hex 31 32 37 33 34 35 35 36 36 37 value of characters 1273455667 Here i have written the code to display but i don't ...
1
vote
2answers
28 views

Script to Ping an IP and create a log showing date/time of any fails, times over 500ms, and traceroute any fails [on hold]

Like the title says I am trying to make a script to run constantly that produces a log showing ping stats. I want the log to contain and ping fails, times over 500ms and the traceroute of any ...
1
vote
2answers
40 views

Substrings in shell script

Am trying to get a substring from a string but am getting the error: ${curr_rec:3:4}: bad substitution #!/bin/ksh get_file_totals() { if [ -e "$file_name" ] then IFS='' ...
3
votes
1answer
30 views

Auto disconnect from WLAN if unused

For Nokia N900 there is an app called AutoDisconnect which monitors the WLAN usage and closes the connection if the traffic is very low. I'd like to have something like this on my future notebook in ...
-1
votes
0answers
17 views

Need a help on .gs script file

I am placing a sample Script code below, the file extension is .gs. I wanted to know what kind of script file it is and what script language is this and how do we compile this script in Linux ...
3
votes
4answers
6k views

Understanding boolean operators in bash script

phone_missing=false echo "missing $phone_missing" if [ ! $phone_missing ] then echo "Lost phone at $readabletime" $phone_missing=true fi I just can't wrap my head around this, as ...
19
votes
5answers
1k views

How can I propagate my SSH pub key to a list of servers without having to type my password in over and over?

I was recently given username/password access to a list of servers and want to propagate my SSH public key to these servers, so that I can login more easily. So that it's clear: There is not any ...
1
vote
1answer
35 views

VBox on headless server: install linux without RDP

I have script to setup headless machine on remote headless server, connected by ssh. It will create machine, attaches disk and archiso, and launches installation. Also, I have script to setup ...
8
votes
3answers
9k views

What is IFS in context of for looping?

I'm learning bash scripting right now. I was reading this thread: How to loop over the lines of a file? What is IFS? With for and IFS:
0
votes
0answers
18 views

Script requesting information upon boot

The idea is to create a script that runs as root upon boot (either before a potential X or GDM starts or after). The challenge is that this script needs input from "the one at the keyboard" - without ...
74
votes
6answers
45k views

Allow setuid on shell scripts

The setuid permission bit tells Linux to run a program with the effective user id of the owner instead of the executor: > cat setuid-test.c #include <stdio.h> #include <unistd.h> int ...
7
votes
5answers
673 views

Modify a file without creating another file

Is there a way to modify a file without writing the contents to another file, without sed and awk? For example: $ cat test.txt aaa aaa bbb ccc ddd Replacing using sed with -i option, sed -i ...
0
votes
2answers
59 views

export PATH permanently [duplicate]

I have exported the PATH but once I switch to a different terminal or reboot Debian, $PATH is reset. Here are the steps I take: ~$ vim scripts.sh #!/bin/bash echo "Hello" I save it as mybash.sh ...
2
votes
2answers
590 views

securely automating a script which requires a key to do its task

I have a script that downloads bank transactions to store in a database. To get these transactions requires a password for each account. The database is encrypted and requires a key to access it. All ...
2
votes
2answers
4k views

grep output of expect script

I'm trying to run some expect language, and grep/parse the output all in one script. I want to grep the output of and look for "error" (I should note that standard linux commands like awk, sed, grep, ...
1
vote
2answers
1k views

How to detect the command interpreter from within a shell script? [duplicate]

Possible Duplicate: How to test what shell I am using in a terminal? I want to detect which interpreter a shell script is using. For example the following script: #!/bin/bash ...
4
votes
5answers
4k views

Javascript to HTML converter?

Take for example this snippet of code on a web page. <html><body> <script language="javascript"> document.write("The cat"); document.write(" sat on the mat"); </script> ...
1
vote
1answer
38 views

Shell read script for sftp

I have this working: % cat read.sh !/bin/sh file=list.txt while read line do echo "$line" cut -d' ' -f27 | sed -n '$p' > file2 done < "$file" % cat list.txt sftp> #!/bin/sh sftp> ...
0
votes
2answers
68 views

Cron job which runs every 5 seconds

I need to create an cron job with the following functionality: The job should go to a particular directory and touch one file every 5 seconds. It should run for only 1 minute. The logic is to ...
1
vote
3answers
52 views

Remove special pattern ^M from script which got appended after FTP from windows to Unix

I send a windows file using FTP to an unix system and got appended ^M wherever a new line was intended, and I just want to remove them. One method which I can opt is to run dos2unix command. Can ...
1
vote
0answers
69 views

How to set Ruby GEM_HOME and GEM_PATH

I'm a NOVICE user of Linux and using Linux mint 17.1 I've reinstalled Linux mint 20 time in last 3 days for that issue but could not fix it I'm trying to install ruby on rails using rvm what ...
0
votes
1answer
34 views

Take output field data string into variable

I want to grep for some specific lines from a log file, and then capture a specific part of that output in a variable and use it in other commands. The grep command I have is the following, where $1 ...
1
vote
0answers
34 views

What's in your script Swiss Army knife? [closed]

I've been using Linux pretty heavily that past few months and I want to up my game. But so far my scripts have been focused on speeding up my development time. I'm looking for scripts that will just ...
1
vote
2answers
1k views

How to run java service as a non-root user on CentOs 6

I have a script that starts a Java application as a service on CentOS 6: #!/bin/sh # chkconfig: - 80 20 SERVICE_NAME=cn4server PATH_TO_JAR=/usr/local/share/myserver/cn4server.jar ...
4
votes
2answers
91 views

Checking if a command is a built-in in ksh

How can I check if a command is a built-in command for ksh? In tcsh you can use where; in zsh and bash you can use type -a; and in some modern versions of ksh you can use whence -av. What I want to ...
2
votes
2answers
520 views

Import single rows from SQLite to MySQL?

I need to do some kind of incremental import again and again from a SQLite 3 database to a MySQL database. Column names are the same in both databases. Is there a good way to do this by a script ...
1
vote
3answers
233 views

How can I run a program as a root user when my Ubuntu 15.04 machine starts up?

On Ubuntu 15.04 I have this file: /usr/local/bin/myscript (it's a script I made). If I run this command under my account, it will do what I need it to do as a root user: sudo /usr/local/bin/myscript ...
2
votes
2answers
528 views

Script that unpacks a initrd, allows editing of the preseed.cfg and the packs it to cpio and gzip again

I want to program a script that allows what is said in the title. So basically I gunzip the initrd, than unpack the cpio, open vi to allow editing, save, pack with cpio, and gzip again, so nothing ...
6
votes
4answers
21k views

Storing output of command in shell variable

I have an operation using cut that I would like to assign result to a variable var4=echo ztemp.xml |cut -f1 -d '.' I get the error: ztemp.xml is not a command The value of var4 never gets ...
7
votes
6answers
6k views

Extracting nested zip files

I have numerous zip archives, each of which contains a number of zip archives. What is the best way to recursively extract all files contained within this zip archive and its child zip archives, that ...
1
vote
2answers
57 views

Pipe to my own script

I've recently noticed this message from grep "grep: warning: GREP_OPTIONS is deprecated; please use an alias or script" I receive this warning because --color=always is defined in my .bashrc file. ...
-7
votes
0answers
38 views

UNIX script to display the filename [duplicate]

How to answer the below interview question: With a path and filename of "/mydir1/mydir2/mydir3/myfilenane.dat" write a UNIX script to display the filename
3
votes
1answer
38 views

Solaris: PKG - Script To Verify All Packages Except for a Few

I'm trying to verify the all packages except for a pre-defined list of packages that I know are going to fail for known reasons. This script is going to be run on all Solaris systems within our ...
17
votes
5answers
27k views

File extensions for unix shell scripts

On wikipedia, the article for .sh says: For the .sh file extension type, see Bourne shell. How about other unix shells? I know that the shebang is used inside the file to indicate an ...
2
votes
1answer
33 views

Scripteable GPT partitions using parted

I am partitioning eMMC using following commands in the script, parted /dev/mmcblk0 --script mklabel gpt parted /dev/mmcblk0 --script mkpart primary ext4 32MB 132MB parted /dev/mmcblk0 --script mkpart ...
9
votes
7answers
971 views

How to merge text of alphabetic lines with the numeric lines in shell?

I Have a file that has text like this: AAAA BBBB CCCC DDDD 1234 5678 9012 3456 EEEE 7890 etc... And i want to match up the Alphabetic lines with the Numeric lines so they are like this: ...
0
votes
1answer
71 views

Shell Script Help - Automatically assign users to group

Recently, I have just started to learn linux and I am currently trying to make a shell script that can automate the task of creating user accounts, assigning them passwords and then assigning them to ...
-1
votes
2answers
32 views

Extracting certain data within a script output file

We have a script that runs several commands and rolls up all the output and inserts in into a log file. One of the commands it runs is "netstat -anp". I'd like to be able to search this file for all ...
0
votes
1answer
1k views

How to execute Netscaler commands through a remote machine via SSH connection

I have been trying to execute some NetScaler commands like "bind" & "unbind" through a Linux Box via an SSH Connection. Now the Problem is, Manually we are able to enter & execute commands on ...
0
votes
3answers
72 views

Remove lines in a shell script

I have this file: # more file.txt 2c2 lns-ld-wall-01-t2 old:261,260 4c4 Prive_ORANGE old:258,259 I need to remove all lines like this one 2c2 and this one 4c4. How can I do in a shell script?
1
vote
3answers
66 views

Difference between sh -x and ./ for script execution

So I have a simple shell script. What is the difference between the two commands in execution? Is there a preferred way? $sh -x foobar.sh OR $ ./foobar.sh I found the script executed slower when ...
2
votes
3answers
4k views

Awk printf number in width and round it up

I need to printf a number out, but with given width and rounded (with awk!) %10s I have this and somehow I need to connect the %d but everything I do, ends up with too much parametres for awk ...
46
votes
9answers
62k views

Looping through files with spaces in the names?

I wrote the following script to diff the outputs of two directores with all the same files in them as such: #!/bin/bash for file in `find . -name "*.csv"` do echo "file = $file"; diff ...
4
votes
3answers
857 views

Why read works if stdin is redirected to fd4?

What does the following script mean? exec 4<&0 0</etc/XX/cfg read line1 exec 0<&4 It redirects fd0 to fd4, and "/etc/XX/cfg" to fd0. So why does read still work, shouldn't that ...
10
votes
9answers
24k views

Automatically run commands over SSH on many servers

There is a list of IP addresses in a .txt file, ex.: 1.1.1.1 2.2.2.2 3.3.3.3 Behind every IP address there is a server, and on every server there is an sshd running on port 22. Not every server is ...
0
votes
1answer
25 views

Filtering Log Output on Separate Lines

I did a recursive grep in a directory to find all files that would match as follows grep -ER "match_string1|match_string2" /path/to/dir/ What I get as output is: ...