0
votes
0answers
22 views

Tutorial: How to run a script as root when user logs in [on hold]

I needed to run a script as root when I logged in. I figured out how to do this. In terminal, become root (sudo su). Copy your script to /usr/bin: cp script.sh /usr/bin Make the script executable: ...
0
votes
1answer
32 views

shell script to function on subfolders

I want to write a simple shell script that will go into all the sub-folders in a directory, and organise the files in the sub-folders into new directories. Basically in terminal it would look like: ...
2
votes
1answer
38 views

Bash script callable from home but not scripts directory

I'm having a very weird error when trying to make a script callable. I have a scripts directory in /srv/projectname/scripts where I store you know scripts to be called as cron jobs for different ...
4
votes
3answers
74 views

How to check the number of fields given to the `read` command?

I have a quick question relating to $# in the shell scripts. So, I can use $# at the command line to check the number of a shell script arguments given by the user. Example: # ./shellScript varONE ...
1
vote
1answer
43 views

Bash script for execute one command for many files

I just tried to clear my holiday video stuff and found program for stibilizng vision. There are a lot of files so I made script to stabilize all. Firstly I need to run command: transcode -J ...
-3
votes
1answer
39 views

Scripting downloaded programs

I downloaded a game for fun and I would like to add it as part of my code for my butler program. Say I have the game moon-buggy and I would have this code run it. if [ $word = "buggy" ] then ...
0
votes
2answers
35 views

lscpu output differs when called indirectly?

I use lscpu | grep 'MHz' to get my clock speed. I am getting different results based on the method I am calling this command. Method 1: typing it in the terminal CPU MHz: 1200.000 Method 2: ...
1
vote
1answer
31 views

zip I/O error: Protocol error in bash script

so here's the script that i am trying to get it work: #!/bin/bash filePath="$1" fileName="$( basename "$filePath" )" backupDir="/my/backup/dir/${fileName}-backups/" dateTime=$( date ...
4
votes
2answers
268 views

regex search works with `grep -E` but not with bash script?

I use the same regex with grep and it gives me a match but when doing it in a bash script, it return no match. Test String(part of the file testregex.txt): <a ...
1
vote
3answers
65 views

Run Bash Script in Client from Local Server?

I wrote a bash script for my use and it works. I want that script to be put in some server in my network and call that script in laptops / desktops in my network itself to execute. Any way I have made ...
1
vote
1answer
65 views

Need script for ubuntu

Need a script to use in ubuntu I've bunch of .tgz folders in folder A, each tgz is having some files and tar files, inside the tar files there are folders and sub folders. Wants to move a particular ...
0
votes
1answer
58 views

How to clear history from a script? [duplicate]

I am writing an script to dump my history log into another file "myhistory.log", and then clear that history. I have written the following set of commands: date >> myhistory.log history ...
1
vote
1answer
71 views

How can I alphabetize a multi line record from a text file?

Hi I'm working with bash script and I have example.txt below. How can I alphabetize the following 4 information about restaurants by the restaurant name and print it out? Note that the format when ...
0
votes
0answers
18 views

Automatic shut down and reboot at specific time [duplicate]

I have an assignment that requires me to write a script that shuts down a server at 11pm and reboots it at 6am daily. So far, I have only written a command to shut it down but I do not know how to ...
2
votes
2answers
28 views

How can I write a script to install BleachBit only if the version installed is not a certain version?

I want to write a bash script to download and install BleachBit from a .deb file only if the version already installed is not 1.0. I am using Ubuntu 12.04 and Bleachbit is only version 0.9 in the ...
1
vote
2answers
72 views

Selecting multiple files with in bash

I want to use Scriptreplay with multiple log/timing files located in the same Directory. The script I have right now looks like this: select timings in /mnt/home/$USER/shell_logs/*; do clear ...
0
votes
1answer
65 views

Using for loop to create a flexible radio list in a dialog box from a shell script

I want to create a little Program using Dialog to play logfiles created with Script. The problem is that I can't get a dynamic radio list that automatically adds a row if a new logfile is created. So ...
3
votes
2answers
58 views

How can I check for apt-get errors in a bash script?

I am writing a bash script to install software and update Ubuntu 12.04. I would like the script to be able to check for apt-get errors especially during apt-get update so that I can include corrective ...
4
votes
1answer
35 views

Can't login after adding script to /etc/profile.d

I have created a little script to add bookmarks in Nautilus to redirect users to network share. If I run the script manually, it works brillantly but as soon as I try to add it in /etc/profile.d, I ...
5
votes
3answers
192 views

Evaluating a string in shell script

I am following this bash shell scripting guide: http://www.tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html In the section Numeric Comparisons, it cites an example: anny > num=`wc -l ...
1
vote
1answer
242 views

NDK_ROOT enviroment variable defined but script does not see it

In my ~/.bashrc i have this: export ANDROID_SDK=~/Devel/android_dev_x64/sdk export ANDROID_NDK=~/Devel/android-ndk-r9d export NDK_ROOT=$ANDROID_NDK export ...
1
vote
2answers
46 views

Echo command with color option in script and command works differently

If I run echo -e "\e[1;31mThis is red text\e[0m" in comand line, It prints out red text. However, if I use write it in script file test.sh #! /bin/bash echo -e "\e[1;31mThis is red text\e[0m" run ...
2
votes
1answer
63 views

Run .bash_profile script at login

i'm working on a deb package that allows the administrator to create another account and run that account automatically in kiosk mode. I created the user, specified a shortkey and put that in a hidden ...
1
vote
1answer
63 views

Call shell script “inline” in another shell script

So the bottom line here is that I am trying to have one go-to script work to set environment variables (let's call it setenv.sh) that will be used in subsequent scripts. In Windows (I know, that is a ...
1
vote
1answer
245 views

Run bash script from php

I want to run a shell script within a php webpage to check some processes running on my system (Ubuntu 12.04). Googleing I've found about shell_exec() but I can't manage to run the script when loading ...
1
vote
1answer
54 views

Script not running in crontab, file not found

I need your help to run a bash script in crontab. As many other posts in askubuntu I'm facing the problem that a script that is properly running in terminal mode does not run in crontab. The error I ...
3
votes
2answers
72 views

How to unistall a program installed by a .sh installer?

I downloaded a .sh program (in this case is a game) and then I installed using "sh name.sh" (or maybe it was "bash name.sh". I don't remember quite well, but I guess it has no importance in this case ...
3
votes
2answers
132 views

How to make sed works with break lines from file?

I'm adapting this script to insert file's content into another file. This is what I have now: #!/bin/sh # Check if first and second parameters exist if [ ! -z "$2" ]; then STRING=$(cat $1) # ...
0
votes
4answers
64 views

Basic bash printing question

I know this question is basic knowing how to write script, but I didn't learn that yet: I have a program that takes, as an input, a list like: str_1,str_2, etc. The string is always the same, but the ...
4
votes
2answers
194 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
168 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
46 views

How can I get a file's UbuntuOne URL from the terminal?

How can I get the UbuntuOne URL from a file in a bash script? Here's what my script does so far: I run the script via Nautilus Actions, and it requires one parameter and an URL in the clipboard. The ...
1
vote
2answers
82 views

how to write a script that will execute xampp start and stop

I am trying to write a script that will enable xampp start and xampp stop with the same script without having to write in the terminal everytime. To start xampp, I write in console : sudo ...
1
vote
2answers
119 views

Create a Screen session with a bash script using contab

I want a .jar file to run every time the server boots up (we're using a VPS), and so I've edited crontab using crontab -e and then adding @reboot bash /home/bash/startserver.sh. But I haven't even ...
0
votes
1answer
24 views

script to backup file deleting file

Working on a bash script to take backup of a file, but the problem i get is that mv delete the file or rename it and create a file with the backupname. Script: test="/home/sysadmin/test/hei2.back" ...
1
vote
1answer
53 views

How to check if a restart of open-iscsi was ok

I am working on a bash script to connect a iscsi initiator to a target. After I have edited the iscsid.conf in the initiator I have to restart the open-iscsi with the command: service open-iscsi ...
1
vote
0answers
43 views

Can I open a new terminal with a new binary executing in it?

I tried to write a script that opens a new xterminal with some binary file(not command) running in it.The whole script looks like this: #!/bin/bash XTERM="/usr/bin/xterm -bg WHITE -e ...
2
votes
3answers
304 views

How can I run this sh script without typing the full path?

I'm still very new to Ubuntu. I'm using 12.04, and I'd like to know if there is a way to run this program/shell script without typing: /opt/idea/bin/idea.sh It's kinda tedious and I'm quite lazy. ...
1
vote
1answer
39 views

Check if connection worked if not return error

Working on a bash script to connect a iscsi client to a server. How do I put this command: iscsiadm -m discovery -t st -p 10.0.0.30 in a if to check if the connection was established, if not it ...
0
votes
2answers
45 views

Start-up / Reboot scripts for different users

I'm still trying to learn a little more about bash scripting and start-up / reboot, I have read about crontab @reboot and also just looking at other options but I just wondered if someone could maybe ...
3
votes
2answers
133 views

How to create a native application from a Shell Script?

I created a little application using Bash and Zenity that I wish to install on my system as a native application as well as a package that I can distribute. I have a .desktop file for my application, ...
1
vote
1answer
79 views

Script to rename files

I appreciate any help in advance. I have written a script to rename all .BMP files, and it seems to work, but I get the following error/message for each file: IM2019.BMP mv: cannot stat ...
5
votes
1answer
102 views

Oneliner command to use kill given tcp port number instead of PID?

I often do e.g. sudo netstat -lpn |grep :8088 view the output tcp6 0 0 :::8088 :::* LISTEN 11189/java and then sudo kill -kill 11189 I'd ...
0
votes
0answers
27 views

A script which can be run from a flash drive and modify startup applications

So I have created a script I would like to run on computers at startup on the network I manage. Each is unique, so merging settings accross the network would be problematic. I could change each ...
3
votes
4answers
300 views

grab volume name of volumes over 85%

I want from the output below grab all the volume names that have a capacity over 85%. I know that there isn't one in ths example but lets pretend there is. :) Filesystem total ...
0
votes
2answers
140 views

Why script with /bin/bash is working, with /bin/sh not?

My friend asked me why this two simple script are not working in both shells: Test File "abc.txt": aaa 111 bbb 111 ccc 111 ddd Script #1 (a): #!/bin/sh while read -r line ; do echo ...
2
votes
1answer
53 views

Bash script to check if mdadm is installed if not install it

I am currently working on a bash script to create raid5 with 3 disks and one hotspare. I am confused of how to create a script which first check if mdadm exist, if not it will install it and name it ...
2
votes
2answers
179 views

Temperature & RAM monitoring script

I have the following script: while : do clear; echo "---------------------------RAM Load------------------------------$ free -mt >> memory.txt; free -mt; ...
-1
votes
2answers
92 views

Bash script download dynamic directories

How to download the most recent packages in deb files (all in a folder) for my platform (x86_64/i386) & distro with bash script? There is no PPA for this apps. So I'm interesting in ...
0
votes
1answer
50 views

System Monitor Script

I created a simple script written in bash to constantly monitor my system temp and RAM free. while : do clear; echo "---------------------------RAM ...