Programming :: Create A ZIP In Perl Without Storing Path Information?
Mar 1, 2010
I have the following code snippet:
Code:
my $file = 'test/mybigfile';
my $zip = Archive::Zip->new();
my $zipped = $zip->addFile($file);
[code]....
it simply takes a file (in this case, "mybigfile") and creates a ZIP file containing that file only. Now, my problem is that when I go to decompress the ZIP file, it creates the relative (or absolute, depending on case) path of the original file. To make an example:
Code:
$ pwd
/tmp/perl
$ ls -R
[code]....
What I need is *not* to store the path information inside of the ZIP file, so that once I decompress the ZIP file I only get the original one without having paths created.
I need to extract the Info from the RC column for the first 4 players of liverpool. The test code i have does the same,but can anyone show me a better way of doing it.I could do it easily with gawk -F"|" and print the respective column,but i need to do this in perl.
I'm the server guy which is why I don't know this, but were staging a new webserver and we use some custom perl scripts and as were moving the site over for testing, apache is blowing a perl error;Can't locate web.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.10.0 /usr/local/share/perl/5.10.0 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) at /home/mcp/htdocs/cgi-bin/newgraph.gif line 11.,Now I can copy that file local, but there are a bunch of things, so the question is how do you globally add a folder to the perl search path
I need to get some information like cpu usage,free memory,swap memory and other information from a bunch of remote hosts.Can any one tell me of a good perl module which does that.I dont want to use Net::Rsh or Net:SSH.
I've been looking for a tweak that would allow me to store temp and log files in ram. I've found a few that involved editing the fstab file, but they were either Ubuntu articles or they were over a year old and perhaps didn't apply to Fedora 14.I hear there is also a 'noatime' command that can help speed up processes by telling the kernel not to saved when files are accessed.And what are the advantages and disadvantages of noatime, and writing log/tmp files to ram?
I would like to create perl script that take the default value instead of waiting for me to enter the enter. I have running script that make key for vpn and when I run the script it will start creating key and then ask me questions like what is your country[:us] what is your state name[:nj] ......
so every time I just have to enter cause I need to enter only default values. So is there any way that I can create script that just take me directly to the end without waiting for me to enter anything and taking by default values.
I am new to scripting and I have planned to create script which gives me network computer inforamtion. therefore, I want to know how to write script that sends me computer information to my email add.
I'm running Apache on Centos 5.5, with active SELinux, and I'm having trouble getting my Perl script to write a file that doesn't yet exist to a folder which has the proper security context.
I'm taking here about tins of directories, thousands of files. I'm looking to find a command that makes me able to move the results above to another path, and to create that path once it doesn't exist like below:
I have 2 images stored temporarily in home folder totaling 21 gigs. I recieved warning stating that home disrectory is full.
I used gparted and resized extended partition and home partition. When I look at disk usage it still says that I'm maxed out in /home/edward. How do I increase my share as I have plenty of space. Or, can I create a place for storing images? Also the images were created and placed there using clonezilla.
I had a problem recently, where a perl script was consuming server resources. I found out it was a perl script by using "top". But it didn't give the path to the script. Nor did ps.Also, ps -ef showed that the process with that pid is /usr/bin/httpd (apache), so it must have been apache serving some perl page I suppose.Is it possible to get the path to currently running perl script, if I only know the process PID of the perl process that is running that script? If so, how? I don't need the path to the perl binary, I need the path to the perl script that binary is currently executing.
Java applet not loading image with relative path(e.g. images/1.jpg) but loads image with absolute path(i.e. from /root/user/images/1.jpg) . This is a problem when i want to host the applet on web server
I'm writing a command-line flash card program in Python. I've tried many existing applications, but none fit my specialized needs.
All of the words I'd like to study are manually added to a text file (study.txt). Each time the software is loaded, it checks for new words in that file and also compares them to a dictionary (a tab-separated file, dictionary.txt), and adds that to a matrix. The flash cards are thus automatically generated from study.txt and dictionary.txt.
Now, the software must manage lots of information about each word I'd like to study and add new information made while interacting with the program (such as when that word should be studied next).
That seems easy to put into a matrix. But what is the best way to put that information in a place where I can pull it back when I run the software tomorrow? Do I need to save the matrix to a CSV file, then convert the CSV file back to a matrix the next time the application is run?
I have a program that sends QByteArray datagrams over a udp socket. I would like to have 4 bytes of the datagram that contain a 32 bit integer. When saving numbers to the QByteArray, I have tried the static function number(int) and member function setNum(int), but they convert the integer to its decimal string representation and save that in the byte array. So if the number were 10, it takes 2 bytes, if it were 10,000,000 it takes 8 bytes. This wastes space, and makes it more difficult to get the number when it is packed with a few other pieces of data in the same datagram. Is there a standard way of doing this in Qt?
I have a variable in which the data is stored as below:
variable_test=0m0.001s 0m0.001s 0m0.001s 0m0.001s 0m0.001s 0m0.001s .....an so on.
There are lots of values in format like "3m1.057s" are stored in variable_test separated with an space between two such values. For exapmple, value is "3m1.057s" I need to save different parts of a value in three separate array variables such as the
var_hour=3 var_min=1 var_sec= 057
tell if this can be done using "awk". A "WHILE" loop might be used to separate and store theses values I guess?
where variable would maybe be the output of grep from fileA. So can I store the output of grep in a variable to use it afterwards with awk ?
something like that:
Code: result=`grep prot. fileA` ; awk 'BEGIN { RS = "###" } /'$result'/' fileB > output but that doesn't work. I'm always getting the entire fileB.
The output of grep get stored in the variable, I verified that with echo. So there is something that I just don't get... It seems to me that the above line should work.
Does anyone know how to get the path with a inode number by C programming? Or can I get the absolute path without giving a "path" but a inode number by C?
like this: get_path(unsigned inode); not such this function: getcwd(".", xxx); taowuwen@gmail.com
I have been playing with Linux consistently for a couple of months now. I've been a Windows sys. admin for most of my career, so Linux is pretty strange for me. I started off with computers way back with the TRS-80 and then eventually moved to DOS systems. So the command line interface (CLI) of Linux was not completely alien to me, yet my lack of knowledge on the syntax and commands is holding me back. I have come a long way.
Recently I needed to play around with some DNS settings and one of the commands I used frequently in Windows, IPCONFIG /ALL, doesn't have a direct relative that displayed the same information. If you run ifconfig, it doesn't return the DNS servers you are currently using. You have to run a separate command to retrieve that information.
What I have done is created a super simple script that displays the network information for my primary LAN adapter, which is ETH0 in my case. After that, it shows the domain and name server information. Then it pauses for 20 seconds before closing the terminal window.
Here are the contents of the script file:
ifconfig -a eth0 cat /etc/resolv.conf sleep 20
I simply right-clicked the Linux desktop, choose Create Document, Empty File. I named it something like Network Info. Then I opened it and put this information in it, saved it, and closed it. I renamed the file and added a .sh extension to the end which makes it into a script file. Next, right-click the script and go to properties. In the Permissions tab, check the box next to Execute: Allow executing file as a program. Then click close.
To run the script, just double-click the icon and then click Run In Terminal at the prompt. The terminal window opens, displays the information, and exits after 20 seconds. If you need it longer than that or need a different interface (such as wlan0 for your wireless), you can change or even add that in.
This was all done in Ubuntu 10.10. I know it is very simple and very straight forward and welcome thoughts and feedback about simpler ways to do this. For me, the old-school Windows admin, it's a baby step in the right direction. I am really enjoying learning the Linux OS.
I have multiple drives and software that defaults to my primary drive. I want to change preferences to use my second drive.This is the current path "/home/guy/dvdrip-data" my second drive is named "2Internal".How do I properly format the path statement to use the second drive?
In my script, I need to get execution time of a command (say 'ls') in mili seconds level. For this i tried using "time" command to retrieve the total execution time in milli seconds. But, the problem is that, how to save the output of time command in a variable. The format of the command is like "time ls -R /opt" Going further, the o/p of 'time' command is:
real 0m0.003s user 0m0.004s sys 0m0.000s
Here, in my script, I would like to use only middle line "user 0m0.004s" saved to the variable but unable to find out the way.
I want to monitor my Android phone's network traffic over WiFi. More specifically, I'm interested in which servers are queried (possibly silently) while my phone is connected. How can I accmplish it?
I have installed Wireshark on my box, and have a working usb adapter. How can I make my Ubuntu act like a router, so I will be able to snif packets through Wireshark?
I've got a perl script which generates an html file. What I'd really like to do is send people to just one page (the perl page) which then generates the html and shows the html page in question. Thus the whole transition will be invisible to the user, they'll just have an html page.FYI the perl script generates a list of the users who last logged in to the system, it needs to be up to date (by the second).Let me know if this isn't clear, I understand it sounds a bit confusing...
I am trying to install OpenCV2.2.0 from the sources and to make it easier in the future I want to create a rpm on my OpenSuse 11.2 x86_64 platform. The instructions how to install are in the specfile The relevant parts of the specfile below:
I want to set up an installation server for CentOS 5.5, using PXE for boot, kickstart for package selection (one for server), and NFS for share all files needed.I've succesfully completed a fresh installation of CentOS5 from the DVD for one of my servers (virgil), and I've copied the anaconda-ks.cfg generated by the installer to my install server (beatrix).
Next, I've properly configured the /etc/dhcpd.conf , the /tftpboot/pxelinux.cfg/<IP_CODED> and the /etc/exports for NFS sharing on beatrix.Then, I've copied all the first DVD of CentOS5 content in this folder on beatrix: /opt/CentOS_install I've tried to start virgil from ethernet, and all has gone ok, with the kickstart and so on! But I've decided to apply the updates (new kernel, sudo, xorg, ...), so I've deleted the old rpms from /opt/CentOS_install/CentOS and copied the new ones (downloaded from http://mirror.centos.org/centos-5/5/updates/x86_64/RPMS/). So, I've launched the following commands to recreate the repodata:
But when I try to reinstall virgil, an error message appears, telling me that a package (perl-DBI-...) isn't present in the media.After some debugging, I've noticed that in the /opt/CentOS_install/repodata/primary.xml.gz there isn't the correct path for the rpms. If you look at the original primary.xml, the "path" is like:path="CentOS/abcxyz.rpm" while in the generated file (with createrepo) the path is:
path="abcxyz.rpm".How can I recreate the repodata with the correct path information?
I am unable to create either a file or a directory in a specified path in Linux. I am getting the error "No space left on device". I have checked with df -k and df -i. Free disk space is 28 % and free inodes are 28 %. What else could be the reason?