In shell scripting, a shell such as bash runs a file containing a list of commands (a script). The script is effectively a program and the shell is its interpreter.

learn more… | top users | synonyms

0
votes
1answer
24 views

Shell script issue: cron job script to Restart MySQL server when it stops accidentally

I have this script, I am using it to setup CRON job to execute this script, so it can check if MySQL service is running; if not then it restart the MySQL service: #!/bin/bash service mysql status| ...
4
votes
4answers
221 views

CDIR= $(pwd) gives “Permission denied”

I have a very simple shell script, called deploy.sh #!/bin/sh CDIR= $(pwd) echo Hello World! Unfortunately, running it gives the following error: bird@bird-laptop:~/foo$ sh deploy.sh deploy.sh: ...
0
votes
1answer
19 views

gui builder for shell script

Is there any gui builder tool for shell script. So that the interface can be designed by click and drag. Is there any plugins for eclipse or any existing ide to do this?
1
vote
2answers
30 views

Is there a way to form network connections using shell script?

I want to form a network connection to a website and read the data line by line and store it in a text file in my system using shell scripting. I have done it using java where I can read using a ...
3
votes
8answers
377 views

How to sort by row from terminal

I was looking at this question and I wondered if the following could be done from terminal. I did it in python, just want to see if it could be done from terminal, bash scripting or whatever. ...
0
votes
1answer
38 views

Command to find how much data was transferred from USB

How can I create a cron job that runs every minute and logs how much data was transferred by USB? Ideally I want log of amount the data in bytes transfers done. For example if i tranferred 4mb file ...
0
votes
2answers
52 views

Create , Write and Save file from a Shell script

I don't want to write the file manually, so I made a shell-script. Is there a way to write & save the file automatically without getting the user to press keys? sudo nano blah #write stuff to ...
0
votes
2answers
36 views

Why is this command starting endless terminals and how to make it work?

#!/bin/bash gnome-terminal --command='/home/user23/bin/n-youtube-dl "$1"' I want to pass the argument passed to this script to the other script started in the terminal. But this starts endless gnome ...
0
votes
0answers
11 views

How can run a shell script in openssl? [duplicate]

I have a script called abc.sh. It contains openssl commands. I want to run it using terminal. Can somebody please explain how can I run this abc.sh file in terminal?
0
votes
0answers
14 views

MYSQL redump from a log.sql all or nothing

MYSQL re dump from a log.sql all or nothing mysql -h "$databaseHost" -u "$username" --password="$password" "$databaseName" < /path/to/project/log.sql if this log.sql file contains an error in ...
1
vote
1answer
82 views

Why doesn't this bash script execute on Ubuntu, but does on an online environment?

I can't figure out why this does not work properly on Ubuntu. It works great when I execute the script on CompileOnline; but when I run it on a local server it does not give me the main menu and skips ...
-1
votes
3answers
81 views

How do I replace content of XML file by using shell scripting sed command?

I have a config.xml file which shows: <userid>myUserId</userid> <password>myPass</password> How can I replace myUserId and myPass by using sed?
-4
votes
2answers
61 views

how to check if $1 and $2 are null?

I am running some script which passing the string argument and I want to do if else statement shown as below: if [ $1 != '' ] && [ $2 != '' ] then do something..... but it shown Error ...
2
votes
1answer
22 views

Substituting values on the command line

I want to run sql from the command line: mysql -u user -p database -e "INSERT INTO table VALUES ( NULL, [hash] , NOW(), 0); I want to replace [hash] with the response of another command line ...
3
votes
2answers
261 views

Add strings to a file with commands

I need to add: user_xattr,acl,barrier=1 to my /etc/fstab file. Is there a way to do this via the via shell script? I only want to edit the '/' mount. Here is what I have before I manually edit ...
2
votes
1answer
38 views

How to keep the code running even after the GUI frontend is exited?

I am writing a shell script that runs upon start-up using xterm and asks the user to do things I want him to do. For example, the code is supposed to ask the user to change his password in 1 minute. ...
2
votes
1answer
24 views

How can I group the files in a directory based on their file size

I have a directory where I am writing lots of files but I know each of them fall under one of the 3 pre-determined memory sizes based on what I write. Any file I write may be either 300KB or 129.1MB ...
2
votes
2answers
38 views

Test if operating from live session or not inside a shell script

I have a shell script that can only be run from a live session (LiveCD or Live USB) because it shrinks the root filesystem of an actual installation, which can only be done when the filesystem is not ...
3
votes
1answer
49 views

Move a file and all of its symlinks

For the icon themes I'm developing, I have different files with a different number of symlinks placed in different folders. Here is an example of one of them: FlatWoken/FlatWoken/scalable/apps$ find ...
0
votes
1answer
42 views

Shell Scripting editor in Ubuntu 13.10 [closed]

I want to do some Shell Scripting on my Ubuntu 13.10 (32-bit) desktop. How can I create Shell Scripts using the editor. Since I am not familiar with the Ubuntu editor Gedit. Is it possible to do it ...
1
vote
1answer
31 views

Fire command on client system from server

I have two ubuntu systems one server and another is client. So I have written one script on server, following are the code of script file: Code for login into the client system `sshpass -p ...
3
votes
3answers
292 views

Extract number from string

When using this ubuntu command: ${HOME}/temp/.git describe --always --tags HEAD the output of this command is: v0.1.5-2-p343h3d3 I want to extract 1.5 from the output above and check if it's ...
4
votes
3answers
174 views

How can I process multi-line records with awk in a bash script?

example.txt is below Restaurant: McDonalds City: Miami State: Florida Address: 123 Biscayne Blvd Phone: 911 Restaurant: 5 guys City: Atlanta State: Georgia Address: 123 Peachtree Rd Phone: 911 ...
1
vote
2answers
160 views

linux bash script to create folder and move files

Hello I need to create folder based on a filename and in this folder create another one and then move file to this second folder example: cat.jpg create folder cat create folder picture move cat.jpg ...
2
votes
1answer
64 views

How can I delete a multi-line record from a text file?

For example test.txt contains: Hi Hello Hi world The code below removes a word from test.txt and creates a temp file test_removed.txt which contains the: #!/bin/bash echo -n Enter Input: read ...
3
votes
3answers
135 views

Store output of command into the array

This is command: pdc status -a 2>&1 | grep 'okay' It gives the following output [okay ]: you are currently listening: 33 [okay ]: you are currently listening: 22 [okay ]: you are ...
1
vote
1answer
117 views

execute local bash script in remote machine using expect

I have local shell script. Now, I want to run this local script in remote machine. Of course I can use ssh, but as it(the local shell script) should be like an automated one, it shouldn't ask for ...
2
votes
3answers
91 views

Search and print the lines from the output which can contain lines with errors

I have a command example, device list which gives me all devices with their status as okay or error in the following format [okay ]: you are listening on : 11 [error ]: not currently ...
3
votes
3answers
293 views

Bash Script Difficulty

I'm creating a bash script and I want to create a m e n u. I am a beginner and still a noob but appreciate all your help! When I run the code it displays the menu but the problem is when the user ...
3
votes
1answer
47 views

pkill not killing

I have a Script named PirateRadio.py That I am writing a script for. I need to kill and reload the script. Possibly with the same PID. I thought SIGHUP was a sure thing. when i run #pkill -1 ...
1
vote
1answer
42 views

How can I remove an entry from a list in a shells script?

I have the following script: #!/bin/bash # Bash Menu Script Example PS3='Please enter your choice: ' options=("Option 1" "Option 2" "Option 3" "Quit") select opt in "${options[@]}" do case $opt ...
1
vote
2answers
88 views

Permission denied - running script

I am new somewhat to scripting in Ubuntu and I have the following script which I am executing but getting back Permission Denied messages. Any help is greatly appreciated! Here's the sequence: The ...
3
votes
5answers
246 views

How do I make the shell to recognize the file names returned by a `ls-A` command, and these names contain spaces?

This is the part of the script I am using to rename the files returned by ls-A: for FILE in `ls -A` do ext=${FILE##*.} NUM=$(($NUM+1)) NEWFILE=`echo $2_$NUM.$ext | sed 's/ ...
2
votes
2answers
32 views

where does the shell fall into the process hierarchy?

When you open a new terminal, it becomes the parent process of all processes forked within it. But where does the bash shell, for example, fall into this process chain? Is its parent the terminal? Are ...
3
votes
1answer
38 views

How can “git gui” open repository from parent directory?

I start Git GUI tool using command git gui or git citool. I wanted to add another entry to right click script menu (already have dozens of commands) and created a script like this: #!/bin/sh git ...
0
votes
0answers
100 views

How to use Hadoop streaming input parameter for matlab shell script

Actually i want to execute my matlab code in hadoop streaming. My doubt is how to use hadoop streaming input parameter value for my matlab input. For example , This is my matlab file imreadtest.m ...
0
votes
2answers
33 views

Read file over HTTP in Shell

I want to know if it is possible to read files over HTTP like: $ cat http://example.com/archive/myhouse.txt Is it possible? And is there any extra or better ways to do it? Thanks!
4
votes
2answers
187 views

How do I iterate the arguments in a bash script?

Is there any method to iterate the passed arguments in a bash script? This answer from my question shows me how to use each argument, but I want to iterate them because the number of arguments is ...
3
votes
1answer
149 views

How to check in a bash script if passed argument is file or directory?

I have to write a simple bash script in Ubuntu which would allow me to pass it some arguments and I want to check if these arguments which can contain spaces are files or directories. How can I do ...
1
vote
1answer
44 views

How to see if there are any qbittorent torrents from shell script?

I run a script on startup that opens a browser, irc, and qbittorrent. It looks similar to this: chromium-browser & qbittorrent & xchat & guake & Is there any way I can detect if ...
0
votes
0answers
13 views

Startup script for pxeboot

I am working on pxeboot. Now i want to do startup script in pxeboot server and whenever client started the startup script will run on the client machine. How to do that. ?
0
votes
0answers
18 views

Unmount partition from script, but keep desktop icon?

I dual boot Xubuntu 12.04 with Windows 8. I have a couple of games installed on the Windows side that also work well under Wine. I have a script that checks to see if the Windows partition is mounted ...
0
votes
1answer
63 views

While loop in Shell

I want to make a while...loop statement in my Shell script like: while [ $line < $line_number ]; do echo $line done But there is an error. I think it is because I wrote it in bash code. But ...
0
votes
1answer
75 views

Execute script in sh mode instead of bash in Shell

I added my script called mylovelyscript.sh to /bin/ folder. My script contains code that echos text with different text colors. But when I run my script like $ mylovelyscript it executes in bash ...
1
vote
2answers
175 views

How do I run this sudo command inside a script?

To do a patch manually I must type this command 'sudo ./playback_delete_data_patch.sh 09_delete_old_data_p.sql'. There is a space just before the 09: 'sudo ./playback_delete_data_patch.sh [space] ...
1
vote
1answer
167 views

Console doesn't show pretty UTF-8 characters in Shell

I want to write some pretty, special characters taken from Web in my Shell Console with echo command. I want to write, for example, ▲ character, but it shows me ��� character. How can I solve the ...
3
votes
1answer
44 views

Call a command as if it were in called in another directory

I'm using a command line program whose documentation states: "You can run XXX on input located in another directory, but its output will always be put in the current working directory". I'd like ...
3
votes
1answer
55 views

Ubuntu doesn't calculate expression in [ ..]?

I'm a newbie to Linux. I'm reading the book Linux: Rute Users. Everything is good till I come to Unit 7.1. My script is as follow: #!/bin/sh echo "enter X" read X echo "enter Y" read Y echo "X*Y = ...
1
vote
2answers
190 views

screen shot from command line

I am writing a sh file to take screen short and want to schedule in crontab but when i run the .sh file it run OK no problem happens but when try to schedule it in crontab i got an error like ...
2
votes
1answer
71 views

Writing a script to handle iscsi

I am currently writing a script that (atleast in theory) should install and add changes in config on iscsitarget, but I keep getting an error that I can't seem to figure out the origin of. The errors ...