Script is series of instructions written in plain text file. The script interpreter (i.e. shell, Python, Ruby, etc.) can read this file and act on the instructions as if they were typed at the command prompt. The interpreter also provides a variety of useful programming features to make your scripts ...

learn more… | top users | synonyms (4)

7
votes
3answers
2k views

Why do some python scripts begin with #!/usr/bin/env python? [duplicate]

I noticed that some python scripts start with #!/usr/bin/env python instead of #!/usr/bin/python. Are python scripts the only ones that use #!/usr/bin/env? Are there any scripts that start out with ...
0
votes
2answers
23 views

Can we install a package through a shell script?

I'm trying to write a shell script so that when I reinstall my Ubuntu again. I could just run script and retain all the packages. And I'm planning to pass password in form of argument. My question ...
0
votes
2answers
23 views

Saving work automatically when battery is low

I am a writer and of course I sometimes lose my work if the battery goes dead. I am looking for suggestions for ways to save when the battery gets to 5% or 1%. Maybe a bash command written to save ...
0
votes
2answers
339 views

Shell script options with parsing arguments

I have the shell script CONTROLLER_IP="" if [ "$#" -eq 1 ] then CONTROLLER_IP=$1 else echo "Usage : create_endpoint.sh --controller-ip <Controller IP>" exit 1 fi but its executing ...
1
vote
2answers
33 views

Execute a command stored into a $variable

I made a script where I wrote: COMMAND="/usr/bin/exiftool $PATH_NAME" .... code .... $COMMAND The variable $PATH_NAME is assigned dynamically inside a while loop. The command works fine until it ...
25
votes
7answers
80k views

Not able to execute a .sh file: /bin/bash^M: bad interpreter

I wanted to execute a shell script: -rwxr-x--x 1 root root 17234 Jun 6 18:31 create_mgw_3shelf_6xIPNI1P.sh I tried to do a standard procedure, but I am got this error: ...
0
votes
0answers
4 views

Unwanted Delay in execution of rc.local

I have an few commands in /etc/rc.local to set the clock on a Raspberry Pi (running Ubuntu 14.04) from an external rtc. I would like these to be executed during start up, before I log in to the ...
1
vote
0answers
20 views

after upgrade to 16.04 LTS rc.local not executing command

On previous installed version kubuntu 15.xx i added a line into /etc/rc.local > /home/diet/scripts/my-auto-mount-script which obviously referred to a script that if on home wifi network drives should ...
-2
votes
1answer
29 views

How can i Scripting some of tasks on shell such as Monthly Reminder

How can i Scripting some of tasks on shell such as Monthly Reminder which make a monthly reminder for all users in the system to change their password and Open Ports for make a list of open ...
2
votes
2answers
291 views

Command line IF not working as expected

I'm relatively new to the terminal programming. I'm trying to run an IF condition within a FOR loop. (The command is to be run by a cronjob) for i in {1..5}; do echo $i; if [ $i>3 ]; then echo $i; ...
0
votes
0answers
11 views

Service script is not working

I'm able Start Service With init.d script, however doing service start does not work For eg /etc/init.d/haskal start The service is starting fine and service test start Service not running Ubuntu ...
-1
votes
1answer
31 views

Executing shell script

I have a script: echo "start" cd ~/GoogleDrive/ drive push path-to-file/ echo "done" which uploads path-to file to my Google Drive account. I can run this script without any problem by sh ...
1
vote
1answer
32 views

downloads file in parallel [duplicate]

I have list of url(near about 50k) of images in text file which I want to download. Is there anyway I can download it in async way using wget command or any other way, by reading it from text file.
1
vote
1answer
23 views

Script for Dual boot

I am running file server in ubuntu server with dual boot with windows 7 now i want SCRIPT that can restart the server at the midnight and start to windows 7 and i have put some customise script in my ...
0
votes
2answers
224 views

DHCP on commit script not running

So I have a basic DHCP set up - option subnet-mask 255.255.255.0; option broadcast-address 192.168.0.255; option routers 192.168.0.254; subnet 192.168.0.0 netmask 255.255.0.0 { range 192.168.0.15 ...
0
votes
2answers
31 views

Custom commands with options

How to create custom shell script/command with flags/options ? $ command -t 2 -h "File"
8
votes
4answers
1k views

.sh specifying extension?

Why is it some systems will run a .sh file just by specifying the file name without extension and others require name plus extension? In my case I'm trying to write a series of commands following ...
0
votes
0answers
7 views

Multiple commands to rtorrent

I am trying to modify the .rtorrent.rc file because I need to run, if possible, 3 commands after a torrent is completed. The task would be : Get the dirname and print it to a file Move the files ...
0
votes
1answer
19 views

Syntax error near unexpected token `newline' while installing Predictionio

I'm new to Prediction.io and when I try to install it following the instruction at this page I get the following error: bash: -c: line 0: syntax error near unexpected token `newline' bash: -c: line ...
2
votes
2answers
92 views

How can I show an icon in the panel if (and while) a certain process is running?

I have a script that works in the background. I would like to show an icon in the panel (only) if it runs; it should not show if the script is not running, just like the Dropbox icon. How can I ...
18
votes
7answers
28k views

How to run scripts without typing the full path?

I'd like to know if there is a way to run program/shell script without typing full path: /opt/idea/bin/idea.sh
0
votes
2answers
27 views

crontab doesn't seem to work and makes different schedule in cron.d!

sudo crontab -e lets me edit the crontab, and I put in this: # Hourly backup 0 * * * * rsnapshot hourly # Daily backup 0 2 * * * rsnapshot daily # Weekly backup 0 4 * * 6 rsnapshot weekly And it ...
0
votes
2answers
14 views

How to start Crontab before login?

Basically I have a script (.sh) that syncs a local folder with an FTP one (using cron to run this). This script needs to be ACTIVE AT ALL TIMES (business use :D) and the only thing I cant control is ...
0
votes
0answers
15 views

How can I run a script when click on soft-link to directory on other partition?

I have created a link to directory on windows partition on Desktop in Ubuntu 14.04. Because this partition will not be automatically mounted at startup the link is marked broken each time I power on ...
0
votes
0answers
20 views

Need help with Bucket Brigade Script [on hold]

I want to write two scripts, brig and passer. The brig fire n command starts a fire with a n size. The brig status command displays the status of the fire. The brig quit command just exits the fire ...
2
votes
1answer
952 views

Run script with arguments as sudo without being asked for password

I have two programs in Java that I'm calling from bash script: java program1 arg ... arg sudo java program2 arg ... arg I want to run program2 as sudo without being asked for password. I'm aware of ...
3
votes
1answer
52 views

Auto dimming laptop keyboard backlit when idle

On Windows 10, my laptop's keyboard backlit automatically turned off after a minute or so of inactivity. As soon as any activity occurred, they turned back on. On ubuntu, if I run the following echo ...
3
votes
1answer
453 views

How can I draw selection rectangle on screen for my script?

I am trying to make a simple screencasting bash script. I want to get screen selection coordinates by drawing a red rectangle with mouse. I can use xdotools to get coordinates but how can I draw ...
0
votes
2answers
41 views

How to write a recuring bash script

I created a program that requires a sequence of command line instructions to scrape new information and update the databases. Is there a way to automate this process so I don't have to type all this ...
-1
votes
1answer
66 views

force to use Python 3

i want to port Python Scripts to python 3. How can i force Ubuntu to use python 3 instead of python 2 which is installed, as well. Due to the size of the project, i'd prefer not to write something ...
0
votes
3answers
2k views

Can't run shellscript with sudo

When I try to run my script like this: sudo ./connector.sh It give me this: sudo: ./connector.sh: command not found What am I doing wrong?
0
votes
1answer
11 views

Protect root-owned script against tampering and run unattended w/ sudoers' NOPASSWD

Using /etc/sudoers I gave a non-root user (anyuser below) permission to sudo-execute a root-owned script (test-script below) with the NOPASSWD: tag set. The script's permission octal value is 0550. ...
6
votes
4answers
4k views

How to shutdown Ubuntu after (2 hours) of idle?

Running: Xubuntu 14.04 32bit. I have read several outdated, not working, working different that I want answers here and elsewhere. I had a script that resulted in shutting my Laptop down at boot time ...
1
vote
2answers
38 views

Bash script help, check permission 755 on all files in a folder

I'm attempting to create a bash script where I check if all the files of a specific folder (/tmp) have the permission 755. I also need it to delete all the files that don't have permission value 755. ...
0
votes
0answers
51 views

java not found when running Ubuntu 16.04 desktop snappy app

When running this script from within a Ubuntu 16.04 desktop snappy application I get the message /usr/bin/java not found. Also, the application does not create the files and folders in my Documents ...
2
votes
1answer
30 views

How to run a parameter as an alias in a shell script?

I have an alias alias ll='ls -lF'; I created a bash script temp.sh: #!/bin/bash # Allow aliases to work in bash NON-interactive mode! shopt -s expand_aliases # .. and load them source ...
3
votes
2answers
256 views

How to show a notification if a startup application ( or process) failed to start automatically

I added a script to autostart (using "Default applications for LXSession"). Later, I moved folder containing script. As result, autostart command was silently failing. How can I enable warning ...
2
votes
2answers
49 views

Can I have a countdown window show the time until next suspend?

Occasionally I leave my computer unsuspended when I need to go somewhere but I am leaving it with people I absolutely trust and I will be back shortly so no real need to suspend (like if it's family ...
2
votes
2answers
163 views

sed to execute a command as replacement with substitution pattern as argument

I am trying to replace time in a log file by: cat mlog.log | sed -e "s/^[0-9\.]*/\$(date -d @&)/" Why it always first execute $(date -d $&) but not doing replacement at first and then ...
0
votes
0answers
10 views

Why Live Ubuntu terminal freezes at the end of disk cloning?

I had taken Ubuntu whole disk backup using dd command as: $ sudo dd if=/dev/sda* of=/dev/sdc* bs=512 conv=noerror,sync where /sda is computer harddisk and sdc is External Backup USB drive. Later I ...
1
vote
2answers
44 views

vim.desktop - changes lost when terminal exits

I was thrilled to notice a GNOME launcher for vim in the vim-common package after I upgraded to Ubuntu 16.04, since it offers an alternative to gvim (a solid app, though not perfect for my workflow). ...
0
votes
1answer
72 views

How to validate a user's password, with a shell script? [duplicate]

I'm making a bash script for the Ubuntu Terminal. I need to verify the user before the code can continue. How do I ask and validate their existing log-in password?
2
votes
2answers
33 views

Create a script to move files that ignore errors

I can move files in the terminal easily enough. I have a whole mess of stuff submitted by students daily and it'd make my life a lot easier to have one thing I can run of an evening that'll move all ...
1
vote
2answers
52 views

Can I use the terminal to move images to specific dir's using the images 'tag'?

I have a huge folder of images that I've collected over the years that my students use for coursework. It started off with about twenty images so I didn't really bother with file names or any kind of ...
2
votes
1answer
778 views

What start up scripts are executed when a terminal is opened in Ubuntu?

When I open a terminal, it says cannot execute the binary file and the output is something like this, bash: /home/sandeep/bin/uname: cannot execute binary file bash: [: =: unary operator expected ...
0
votes
0answers
22 views

How to send email from script

I'm trying to write a script that will send an email with all the files from one folder attached, then move those files to another folder. I've done the latter bit with a bash script, but I've never ...
3
votes
3answers
5k views

Transmission shutdown script for multiple torrents?

I have written a shutdown script for transmission. Transmission calls the script after a torrent download finishes. The script runs perfectly on my machine (Ubuntu 11.04 & 12.04). #!/bin/bash ...
2
votes
3answers
995 views

How can I programmatically get the PID of the active GNOME Terminal instance?

How can I get the PID of the GNOME Terminal instance I'm using from within a Bash script? I can run xprop _NET_WM_PID and then manually click the terminal window, but I'd like to completely automate ...
0
votes
0answers
17 views

The power supply of my external monitor broke, how can I switch on my internal screen?

Ubuntu version : 15.10 Laptop display : disabled External monitor Dell s2415h : enabled The power supply of my external screen is gone, so I can't see anything on my external monitor but the ...
0
votes
0answers
11 views

Scripts (suddenly) not running from Nautilus

I wrote some scripts, set Nautilus to run executable text files without asking, set the files as executable and everything worked as advertised. I double-click my scripts, they open up in ...