Programming :: Pass Complicated Commands As Argument To Another Script?

Apr 21, 2010

I am attempting to script some tasks I have to do, but I have no control over one of the scripts I have to use... and they output all kinds of useless things on the screen. My goal is simple: Capture all output from their scripts, and create a progress line that only shows the most recent output from their stuff. So, here was my first solution; a file I called "spin":

STRT='date "+%s"'
while [ -d /proc/$PROC ];do
last3=" 'getLine $2' "

To use it, you pass it a process ID and a file that contains the output from that process. As the process continues, a kurby dances on the screen (To let you know that the process has not hanged), and the tail of the output is shown (To let you know what it is doing). When the process ends, the kurby stops dancing and the time it took is displayed.

And here is the file I call "noise":
while [ i -lt 100 ];do
echo "Look at me count!$"
sleep 1
let "i=$i+1"

This does nothing but create random output, for testing. It counts from 1 to 99 on the screen. To run my test, I do the following:
(noise) &>tmp.txt & spin $! tmp.txt

It works relatively well, but it is messy. I don't like creating a temp file, and I don't like the messy syntax for calling my program. I decided that I would rather move everything into the spin program, to make using it less messy:
#Spin Psuedo code
#$1 = command I am about to run
(exec $1) &>tmp.txt & spinX $! tmp.txt

By executing the process inside of the spin code, I can get rid of the tmp file later on without changing a lot of scripts (Or move it, or whatever). I can also call it by passing the command to the script, which I find more elegant.

So here is what I would like to know:
1) If possible, I would love to get rid of the tmp file all together, and store the most recent line of output from script 1 into a variable that script 2 can print out instead... is it possible?
2) How can I run a random command that is passed as an argument? Basic ones work fine, but anything with a pipe fails me.

Example of a script:
echo;echo "Recieved command: ";echo $1;echo;
echo "Attempting to run command: ";echo
exec $1

Example code for passing commands to script:
> "ls -al" #works
> 'ls -al' #works
> "ls -al|grep *.sh" #fail
# Output:
#ls: invalid option -- |
#Try 'ls --help' for more information.
> "ls -al|grep "*.sh"" #fail
# Output:
#ls: invalid option -- |
#Try ls --help' for more information.
> 'ls -al|grep *.sh' #fail
# Output:
#ls: invalid option -- |
#Try 'ls --help' for more information.

View 8 Replies


Programming :: Python : Pass Output Of System Commands To Variable?

Jan 25, 2011

I'm trying to write a python script that will use the current user's name when interacting. Ex: when started, it should say "hello daweefolk" when I am logged in.
I've tried
username=os.system("echo $USER")
but the variable remains empty.
What is the correct code?

View 1 Replies View Related

Programming :: Open Gnome Terminal (pass Commands ) On Clicking Glade Button

Dec 18, 2010

I am working on a small project for making a small configuration tool for ubuntu 9.10 for new linux users, that make their system working easily without knowledge of the linux commands.I created a gui in glade and loaded the gui with my python program to show up, now i wish to have some python codes that can launch a gnome terminal (and also pass some linux commands to it) on the click of a button contained in the glade file.

View 1 Replies View Related

General :: How To Pass Argument From Command Prompt?

Jan 5, 2011

when I am running the script below,it performs on whatever logfile u type ,i.e, ./scriptname logfilename.But how do I convert it into a function and then call it from another script.I mean how do I prompt the user to enter a logname and then capture the name in the function and when calling this function from another script how do I pass the parameter.

View 3 Replies View Related

General :: Pass Kernel Argument To Load Ubuntu?

Mar 11, 2010

The ide has xp and I installed debian on the sata, the duel boot worked fine and still does. I then installed unbuntu on the sata along with debian but can't access unbuntu. when I tryed to install grub it error'd out so I bypassed that and finished the install. It told me I would need to pass a kernel argument to load ubuntu but I'm clueless about what that means.


View 8 Replies View Related

CentOS 5 :: Pass Shell As Command Line Argument When I Ssh To An Account

Jan 25, 2011

I want to have a choice or more preferable pass shell as command line argument when I ssh to an linux account.i.e. If John logs in to account "zzz" on server "abc", by default definition of account "zzz" n server "abc" he get csh.But Sally desires that when she logs in to account "zzz" on server "abc", she needs the login shell to be ksh,and Rick wants bash when he logs in to account "zzz" on server "abc".What is the most non-intrusive / easiest way to achieve this? Each user can set their preference on ssh command line or create a simple alias by each shell, but not sure how to do this.

View 6 Replies View Related

Software :: Use Php To Pass Commands Onto A Server?

Mar 4, 2009

hi all how do i use php to pass commands onto a server? like i want to be able to:

1. delete the content of a file (or just delete the file and make a new one if it's easier)

2. read the content from a file

3. write new data to a file via an input box

4. run a command on the server

View 7 Replies View Related

Ubuntu :: Need Grub To Pass On Some Commands To Secondary OS

Jul 29, 2011

So, I have a netbook with a 320GB harddrive and I'm testing all kinds of fun distros out. Right now I have 11.04, 11.10 daily, Jolicloud, Chromium OS, and MeeGo. Meego uses it's own weirdass boot loader, which sets things up a certain way. My computer has a touchscreen, and I had to modify some things to get it all working properly. Anyway, I reinstalled grub on my main partition (11.04), but now the command I need doesn't go through to meego.

The command is "usbhid.quirks=0x0eef:0x725e:0x40" For my other systems, I have it in /etc/default/grub in the "GRUB_CMDLINE_LINUX_DEFAULT=" line.

Obviously there is nothing like this in Meego, and a thread on their forum said I would have to configure it in whichever bootloader I'm using.

View 3 Replies View Related

Programming :: Pass Variable In Mysql Qyery In C Programming?

Dec 4, 2010

i want to pass variable in mysql qyery in c programming

View 1 Replies View Related

Ubuntu :: Write A Base Script Which Will Divide An Argument By 10 And Then Use That Argument In Another Program?

Feb 23, 2010

I'm trying to write a base script which will divide an argument by 10 and then use that argument in another program. Since my argument can be a floating point number, I used bc to accomplish this. Here's an example of a simplified version of what I have so far:

<code>NUM=$(echo "scale=25;$1/10" | bc)
#make sure the first argument was formatted correctly
if [ $? -ne 0 ]


View 4 Replies View Related

Fedora :: [15] Won't Restart- Kind Of Complicated?

May 28, 2011

When I shut down the computer, then turn it back on- everything goes fine- system loads, no errors.BUTWhen I am in a turned on system, and I ask it to restart (reboot), when the machine restarts and the system starts loading- I get a kernel panic. Every single time- but only when I ask the machine to restart. If it helps, the error didn't appear on Fedora 14.

To make it more colorful- the same situation happens with my Ubuntu 11.04 (I have triple boot- Fedora, Windows and Ubuntu- I am learning Fedora to switch from Ubuntu). When I had Ubuntu 10.10- all was ok- when put 11.04- the error is the same- I can't restart my PC properly. The only system that loads as it should every time is Windows 7.Could anyone pls help me? My guess is that it's some kind of kernel change, because the error didn't show up in the previous versions of both systems (Fedora and Ubuntu).Did memtest (after 12 passes there were still no errors), tried acpi options, modeset, nomodeset (using grub2)- all for nothing.

View 2 Replies View Related

Programming :: Argument Relations In CGI Script

Feb 15, 2010

I have made fallowing script for CGI scripting learning purpose:

echo "Content-type: text/html"
CMD='echo "$QUERY_STRING" | sed -n 's/^.*cmd=([^&]*).*$/1/p' | sed "s/%20/ /g" '
echo "<html>"
echo "<head><title>Hello CGI</title></head>"
echo "<body>" .....
echo "<input type=radio name=cmd value=ifconfig checked> ifconfig <br>"
echo "<input type=radio name=cmd value=uname> uname -a <br>"

This script works fine, but actually I quite don't understand it's inner working about those radio buttons.

View 1 Replies View Related

Programming :: Insert $2 Argument Until The End To Variable?

May 17, 2011

how to insert $2 argument until the end to variable?For example:

>> cucu.csh user "long long message "
$1 = user
$2 = "long long message "

View 10 Replies View Related

Programming :: Making A 1 Command Line Argument?

Jun 8, 2010

I need to write a script that will take 1 command line argument. The argument will be a username. The script will determine if the user exists on the system and will print an error if it does not. If the user does exist it will determine if the user is currently logged in, if the user is not logged in it will determine the last time the user logged in and display the file in the users home directory that was most recently modified.

View 2 Replies View Related

Programming :: Passing The Char * Vector Argument?

Jun 19, 2010

I am trying to simulate a shell. So what I do is checking of having the parameters from standard input, suc as "/bin/ls -l /home/france/Documents", and then passing them to function execute, which at some point calls execvp(argv[0],argv)The problem is that I don't succeed in using these arguments, while if I call execvp(paramList[0],paramList) it works!!!! Where paramList is exactly what I would put on standard input, but defined statically.




View 2 Replies View Related

Programming :: [bash] Option Followed By Argument List?

Feb 6, 2010

I'd like to pass the following arguments to a bash script in any order:

myscript -l <country> -r <file1> <file2> ... -o

I read the argument list in a switch shift loop. I figured out how to read the filelist but only if -f is the last option.

how to position the file list anywhere in the argument list?

View 5 Replies View Related

Programming :: C - User To Input The Name Of A File As An Argument

Aug 5, 2010

Write a program that requires the user to input the name of a file as an argument. If the user fails to include one argument it should make use of a thread that handles a signal. The signal handler should tells the user Incorrect number of arguments and then calls the terminate signal on the process.

If the numbers of arguments are correct then the program should allocate memory space to the file (5MB) and create a child process that requests the user for a character that it should send to the parent. The child should keep request for data until the user keys in the character O. During each request it should pause for 10 seconds, send the character to the parent and then requesting again for another character.

The parent should get the character from the child. Do not make the parent wait for the child to finish requesting for data. Make use of pipes to facilitate communication between the parent and the child. A second child should be created to read and display data from the file. Make use of any appropriate Inter Process Communication technique to ensure that the second child and the parent do not access the file simultaneously (Mutual exclusion).

View 5 Replies View Related

Programming :: CreateProcess() In C \ Specify The Location Of The File As An Argument?

Aug 31, 2010

am coding a chat program in C (win32), where I need both the client and the server to communicate, without waiting for a reply from the other side, like the way we chat in any messenger. Is there any way of accomplishing it? I tried out CreateProcess() function, but am not clear how to specify the location of the file as an argument.If there are better techniques than CreateProcess(), then

View 13 Replies View Related

Programming :: Shell: Give A Range Argument To 'for'

Feb 20, 2010

Feel free to just link to another thread where this is (pre)solved; I can't search the forum for the word "for," because it's too short (or maybe the search engine dislikes prepositions).

Is there a way to give the 'for' command a range? Here's what I mean:

#for i in (1-5); do echo $i; done
Certainly, meat space user; I understand exactly what you're thinking.
True, I realize I could use

COUNT=1 ; while [ $COUNT -lt 6 ]...

...but if I can avoid the extra preparatory step I'd prefer to do so.

View 2 Replies View Related

General :: Minimalist Server - LFS Too Complicated And Time Consuming For End Result

Oct 7, 2010

I am wanting to create the smallest server I can possible. I have a small server I use as a print server and for file sharing. The hard drive is about 80GB. Since I only run cups and samba, I see no reason to take up an addition few GBs with major distros just to run the OS. I know it is possible to get a small distro around 50MB or so. I would even be happy with an OS running around 200MB. what would be the best way to go about doing this? LFS is just too complicated and time consuming for the end result. Would something like Gentoo be better? Anything else that I may not know about?

View 11 Replies View Related

Programming :: Ssh Remote Command Preserve Quoted Argument?

Sep 17, 2009

I have a python script on one server (serv_one) and I am trying to execute it remotely from another (serv_two). The python script takes an argument with spaces. If I execute it locally:


foo@serv_one> --o "arg one"
"arg one" is preserved, of course. ( argv = [ '--o', 'arg one' ] )

However, when I execute it remotely:


foo@serv_two> ssh ... foo@serv_one --o "arg one"

the double quotes around "arg one" are dismissed ( argv = [ '--o', 'arg', 'one' ]. I've tried many combinations of single quotes/double quotes/backslashes, etc, to no avail. One hack solution I came up with, since I have the flexibility, was to replace all spaces in the quoted argument with a character that would be invalid in the argument (before the ssh call), and replace those with spaces in I would probably like to avoid this solution if at all possible.

View 7 Replies View Related

Programming :: C++ Failing To Pass By Value?

Jan 25, 2010

I have a strange problem with a simple program. I have a container class that holds a pointer. I did this so I could use another container class that does several pass by value calls. I didn't want to be copying the object over and over again, so decided to build this simple container that simply copied the pointer in the copy constructor.

However, the pass by value call seems to be failing in a strange way. When the pass-by-value function is called, the program jumps into the copy constructor just fine and performs the pointer assignment operation. The program will copy the pointer value 0x20 (for argument sake) to the "this->base" location. Within the copy constructor, this has the address 0x28. Then when it jumps into the function, instead of pass by value argument being at 0x28 (as expected), it is at 0x36. Then 0x36->base has the address 0x28. Thus the base is now pointing at what was the new pointer container. At this point the data is corrupted and random things happen.

It seems that there is some strange assignment and double nesting going on. I really do not understand what is going on.

Below is some code. I have stripped away all the other code trying to isolate the problem. I have added comments explaining what my debugger is telling me.

using namespace std;
class paramPnt // Need to determine how order is tracked
long order;


View 4 Replies View Related

Programming :: JNI - How To Pass STL Structures

Jun 17, 2011

I hace some code C/C++ STL, which i need to use for android, using problem is that i need to pass some STL structures across JNI, I can't pack/unpack data into basic types or arrays of basic types, doing my own simple streaming between the two layers.My application need to pass a pointer to a STL structure which is updated by eachuser interaction wonder if it is possible using NDK-JNI ?Other option is "native activity" but it also needs JNI in some way ... and passing the STL structures wille a requirement, yet.I only can package data into an own streaming if there is a second (concurrent) application running (implementing the STLfunctionality). Is it possible ?

View 1 Replies View Related

Programming :: C++ Program Calling A Fortran Subroutine With A Function In The Argument?

Mar 9, 2011

I have a new problem; i want to call a subroutine's fortran which have a function in the argument and the compilation ran properly, but when i execute the program this shows me an "Segmentation fault". This is my c++ program:

Code: //Main.cpp
#include <stdio.h>
#include <iostream>


View 2 Replies View Related

Programming :: Handle Non Argument Error While Adding Two Alphabets Using 'expr'

Feb 19, 2011

how to handle non argument error while adding two alphabets using 'expr' (not bc).

View 1 Replies View Related

Programming :: Shell Scripting - Value Disappears Depending On Argument Order

Mar 21, 2011

$ ./ -a -c 2
operator is -gt
remcount is
^ value missing!

$ ./ -b -c 2
operator is -lt
remcount is
^ value missing!

Yet when "-c" is the first argument, its value is present:
$ ./ -c 2 -b
operator is -lt
remcount is 2
What could I do to ensure the value of "-c" is picked up regardless of the argument order?

View 5 Replies View Related

Programming :: Pass Variable Between Scripts?

Mar 9, 2011

I need to pass variable from to and update the value of the passed variable in and then return the updated value of the variable from to

View 7 Replies View Related

Programming :: Pass In Mandatory Arguments First?

Jun 9, 2011

I am using getopts to take parse optional arguments but i also pass in mandatory arguments first

perror "$@"
shift 2

View 8 Replies View Related

Programming :: Make A Template Char Or Wchar_t Default Function Argument?

Oct 30, 2009

I have a template similar to the following.


template <charT>
virtual void do_get_date(charT* = "str")
{ ... }

As you can see we have a problem. If we use a wchar_t instead the string wont be formatted right we need to prefix L in front. If we use char16_t we need to prefix a u in front. Is there a was to make the generic without resorting the the std::string class?

View 2 Replies View Related

Programming :: Pass A Path As A String To A Variable?

Apr 17, 2009

I'm trying to pass a path as a string to an array, but its evaluating it as a command instead. I want to take the literal string "/mnt/accounts/user/temp/*.jpg" and assign it to an array{1}, but when i echo the array variable, it displays it as



I just want it to be the actual text "/mnt/accounts/user/temp/*.jpg" which i will be combining with other text to create a longer path elsewhere in the code.

View 5 Replies View Related

Copyrights 2005-15, All rights reserved