The script receives multiple files as parameters and it is supposed to count the number of lines in each of them and write that number in another file.
This is my script:
Code:
while [ -n "$1" ] do lines=`cat $1 | wc -l` echo "The number of lines in file $1 is $lines." >> lines.txt shift done
Is there any other way to do the same thing, without using shift?
I am very new to shell scripting.How does one pass a command-line parameter to a shell script?for the below program #/bin/bash mount -t cifs -o user=ramkannan,password=Linux123@ //10.200.1.125/ramkannan /MT cd /MT/test date=`/bin/date "+\%Y-\%m-\%d-\%H-\%M-\%S"` mysqldump -uroot -pram2@ employeedb > $date.sql gzip $date.sql
I want to pass parameter for everything,i tried in google and did but iam getting error while passing parameter to all
#/bin/bash mount -t cifs -o user=$1,password=$2 //10.200.1.125/ramkannan /MT cd /MT/test date=`/bin/date "+\%Y-\%m-\%d-\%H-\%M-\%S"` mysqldump -uroot -pram2@ employeedb > $date.sql gzip $date.sql
i was getting error while passing parameter to all.
I have never in a year had a problem with this d-boot system. Two days ago I tried to boot into ubuntu like every day. It started to load normal, went to the ubuntu logo and paused for about 15 seconds and posted this under the logo:
One or more of the mounts listed in /etc/fstab cannot yet be mounted /: waiting for /dev/loop0 /tmp: waiting for (null) /boot: waiting for /host/ubuntu/disks/boot Press ESC to enter a recovery shell
I have looked everywhere and tried so many things, I can't look any further. All I have been doing for two days is trying to boot this system.
I have a problem in my shell script. I try to control an installation.During the installation there are a few questions which have to be answered.Like: "Enter your Choice [1-3]: "I want do something like this:
--> It's my first script <-- #!/bin/bash echo "--> Install packages <--"
Succeeded in connecting to internet using my wll phone. I can now connect using 'wvdial' command in root terminal. But I want to connect through terminal. I tried 'sudo wvdial' command. Then I am asked for my password. But I cannot type my password there. When I type, nothing appears on the terminal window. Ofcourse there's no problem with my keyboard.
I am using ubuntu10.04-server 64bit AMD with fluxbox. After I ran Matlab in a shell (without GUI) the shell does not display characters anymore, but will execute any command, I just can't see the characters that I'm typing.. I use aterm and xterm, does anybody know why that is, am I missing a package?
i would like to know whether it is possible to pass firefox a single cookie generated by some other program (in this case wget), doing it from the command line. my concrete use for this is to login to a site (connect.garmin.com) with wget, saving the cookie with --save-cookies --keep-session-cookies, pass this cookie to curl, do some uploads and then pass the cookie to firefox to open the page and have me logged in automatically (everything besides firefox is sorted out). google searches and the firefox man page suggest that firefox doesn't have this functionallity, but would it in that case be possible to link the cookie into firefox's normal cookie jar?
I'm trying to set up a hot spot using a squid proxy server for network logging of accessed website URLs. I really would like to pass all web traffic through a custom PHP program.Like when a computer tries to access www.google.com it first goes through the proxy server, and then the proxy server sends back a URL like URL...which is then accessed by the end-user's computer.. I'd eventually set up the php program to redirect the user to the requested URL after my application executes.Is this at all possible to do, with or without squid?
Is there any way I can switch my desktop shell from unity to, say, gnome-shell? I can switch using other console shell I like (bash, csh, fish, etc.). Assume that there is a stable alternative desktop shell, I should be able to choose, too.
(For console shell, we goes to /etc/passwd. But for desktop, I can't find the way to config.)
We have a ubuntu machine on the network with number of users in it. Basically, when other users connect via telnet i want then to get particular messages depending on the user. The message will be set by the administrator or a particular user with privs. Similarly we also need a to-do app via which users can update their work and see each others progress . Its all in a local network. Do tell what would be the best way to do it!
I'm using an ubuntu machine to route internet to my main PC. I think I finally got it working with DHCP and all, but there's still a slight problem. DNS does not work! My /etc/dhcp3/dhcpd.conf file contains the following lines:
I am currently only able to post on this forum because I copied /etc/resolv.conf from my server to my main machine. Now DNS is working. But it should update automatically, right? Currently, this isn't working.
If possible, I'd like it most if I wouldn't have to hardcode the DNS servers in /etc/dhcp3/dhcpd.conf either, but that the server would just relay the DNS adress it has gotten itself!
It seems incrontab wont see spaces properly at all. I setup a script to echo the arguments passed to it by incrontab to a file, and no matter what I put around the arguments on the incrontab file it will count a space as the next argument.
I have written a script to automatically retrieve imdb artwork for a given filename. Here is the script:
Code:
You can ignore all the commented "echo" commands that was just me testing. Anyway, the script work fine, however I am trying to use incrontab to monitor a folder, when a new (video) file is moved into the folder, it should execute the script and retrieve the artwork. My problem is, when incrontab passes the $# argument to my script, the script wont work because the spaces aren't escaped.
Here is some more detail:
Incrontab
Code:
Code:
The problem is, the script GetArtwork, doesn't see "Bangcock Dangerous" it just sees "Bangcock"
I have tried putting quotes around the $# in the incrontab - this just makes the script see "Bangcock (notice the single quote character)
I am new to bash scripting. I want to know whether i can pass one variable to another. For example $1 represent argument1. Now if i want to get the argument 1 like USER="1" now i want $ of $USER to execute $1 so what should i do..
I'm struggling with the issue of passing a vector of a class to itself, here's what state its in now... (tried many variations, but without direction).
I'm trying to work out the best way to achieve the following.
1)php page that grabs data from a local database. (not a problem)
2)It then needs to send this data to a c program/service running on a remote server. (I probably need it to be able to handle 4+ million reocrds in an array)
3) The c service then needs to process the data and send it back to the initial php script that called it. i was hoping this could be in a an array like structure of some kind. 4)update the db with the results.
I was thinking of using gsoap to write a simple c soap service that php can communicate with. Would this be the right way of doing this or would something like sockets in php be a better way of sending this volume of data as an array or struct to linux c socket if thats even possible.
MACHINE: HP Proliant DL260G5OS: SLES 11 SP1kernel: Linux xserver 2.6.32.12-0.7-default #1 SMP 2010-05-20 11:14:20 +0200 x86_64 x86_64 x86_64 GNU/LinuxIt is used as remote xserver in a LAN.I have configured /usr/lib/restricted/bin/.rbashrc with some environment variables but when the users logon in the system finally is executed $HOME/.bashrc and some environment vars are overwritten.
I am trying to create a shell script similar to ls, but which only lists directories. I have the first half working (no argument version), but trying to make it accept an argument, I am failing. My logic is sound I think, but I'm missing something on the syntax.
Code: if [ $# -eq 0 ] ; then d=`pwd` for i in * ; do if test -d $d/$i ; then echo "$i:" code....
I've given a bit of support using Mod_rewrite to use magical urls to redirect to scripts, but when I migrated to Ubuntu's Apache2... I'm lost. I basically want to rewrite like this:
Code: RewriteRule ^artist/(.+)/$ artist.php?artname=$1 But I noticed that it wasn't passing the artist=$1 to the server GET vars. Then I noticed that if I changed the name of the file in both the rule and the file system to artists.php, typing artist/blah/ no longer was found. So then I realized that if I removed the rewrite rule artist/hello/ would still resolve to artist.php without any parameters my htaccess is like so:
Using 10.04 and x11vnc I'm finding that upper case characters are being sent as lower case. I've tried multiple keyboard configurations with no success
In short: how to make sudo not to flush PATH everytime?
I have some websites deployed on my server (Debian testing) written with Ruby on Rails. I use Mongrel+Nginx to host them, but there is one problem that comes when I need to restart Mongrel (e.g. after making some changes).
All sites are checked in VCS (git, but it is not important) and have owner and group set to my user, whereas Mongrel runs under the, huh, mongrel user that is severely restricted in it's rights. So Mongrel must be started under root (it can automatically change UID) or mongrel.
To manage mongrel I use mongrel_cluster gem because it allows starting or stopping any amount of Mongrel servers with just one command. But it needs the directory /var/lib/gems/1.8/bin to be in PATH: this is not enough to start it with absolute path.
Modifying PATH in root .bashrc changed nothing, tweaking sudo's env_reset and env_keep didn't either.
So the question: how to add a directory to PATH or keep user's PATH in sudo?
i'm programming a small tcp client, but i need that the server knows the source ip. My client receives a external connection and forwards, but the ip seen by the server, of course, is the client ip. I would like, change this ip to original source ip.
I don't know how to do this. I tried with the connect and select function.
How can I pass xml data from memory or a variable to xmllint that expects a file as input? Or does xmllint have the capabilities to read from stin or a variable?
I'm using gdb to debug my program. My program requires arguments (e.g., ./prog -dfile).But if I use gdb as in gdb ./prog -dfile, gdb wants to interpret the -d argument. How do I pass an argument to my program via gdb?